bugfix, sprites adjustment

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@521 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2008-07-04 22:20:48 +00:00
parent fbc65db755
commit 0fc0e24180
11 changed files with 39 additions and 47 deletions

View file

@ -65,9 +65,9 @@ struct TileStrip
#ifdef _ASM_DRAW_C #ifdef _ASM_DRAW_C
void DrawWindow(int tstart, int tend, int prio, int sh); void DrawWindow(int tstart, int tend, int prio, int sh);
void BackFill(int reg7, int sh); void BackFill(int reg7, int sh);
void DrawAllSprites(int prio, int sh); void DrawAllSprites(unsigned char *sprited, int prio, int sh);
void DrawTilesFromCache(int *hc, int sh, int rlim); void DrawTilesFromCache(int *hc, int sh, int rlim);
void DrawSpritesSHi(unsigned short *sprited); void DrawSpritesSHi(unsigned char *sprited);
void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells); void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells);
void FinalizeLineBGR444(int sh); void FinalizeLineBGR444(int sh);
void FinalizeLineRGB555(int sh); void FinalizeLineRGB555(int sh);
@ -1007,8 +1007,6 @@ found:;
} }
else else
{ {
int old_prio = 0x8000, lo_above_hi = 0;
for (u = 0; u < max_lines; u++) for (u = 0; u < max_lines; u++)
*((int *)&HighLnSpr[u][0]) = 0; *((int *)&HighLnSpr[u][0]) = 0;
@ -1039,37 +1037,34 @@ found:;
if (sh && (code2 & 0x6000) == 0x6000) if (sh && (code2 & 0x6000) == 0x6000)
maybe_op = SPRL_MAY_HAVE_OP; maybe_op = SPRL_MAY_HAVE_OP;
if (onscr_x && !old_prio && (code2 & 0x8000))
lo_above_hi = SPRL_LO_ABOVE_HI;
old_prio = code2 & 0x8000;
entry = ((pd - HighPreSpr) / 2) | ((code2>>8)&0x80); entry = ((pd - HighPreSpr) / 2) | ((code2>>8)&0x80);
y = (sy >= DrawScanline) ? sy : DrawScanline; y = (sy >= DrawScanline) ? sy : DrawScanline;
for (; y < sy + (height<<3) && y < max_lines; y++) for (; y < sy + (height<<3) && y < max_lines; y++)
{ {
int cnt = HighLnSpr[y][0]; unsigned char *p = &HighLnSpr[y][0];
int cnt = p[0];
if (cnt >= max_line_sprites) continue; // sprite limit? if (cnt >= max_line_sprites) continue; // sprite limit?
if (HighLnSpr[y][2] >= max_line_sprites*2) { // tile limit? if (p[2] >= max_line_sprites*2) { // tile limit?
HighLnSpr[y][0] |= 0x80; p[0] |= 0x80;
continue; continue;
} }
HighLnSpr[y][2] += width; p[2] += width;
if (sx == -0x78) { if (sx == -0x78) {
if (cnt > 0) if (cnt > 0)
HighLnSpr[y][0] |= 0x80; // masked, no more sprites for this line p[0] |= 0x80; // masked, no more sprites for this line
continue; continue;
} }
// must keep the first sprite even if it's offscreen, for masking // must keep the first sprite even if it's offscreen, for masking
if (cnt > 0 && !onscr_x) continue; // offscreen x if (cnt > 0 && !onscr_x) continue; // offscreen x
HighLnSpr[y][3+cnt] = entry; p[3+cnt] = entry;
HighLnSpr[y][0] = cnt + 1; p[0] = cnt + 1;
if (entry & 0x80) p[1] |= (entry & 0x80) ? SPRL_HAVE_HI : SPRL_HAVE_LO;
HighLnSpr[y][1] |= SPRL_HAVE_HI; p[1] |= maybe_op; // there might be op sprites on this line
else HighLnSpr[y][1] |= SPRL_HAVE_LO; if (cnt > 0 && (code2 & 0x8000) && !(p[3+cnt-1]&0x80))
HighLnSpr[y][1] |= maybe_op|lo_above_hi; // there might be op sprites or priority mess on this line p[1] |= SPRL_LO_ABOVE_HI;
} }
} }
@ -1302,7 +1297,7 @@ static void DrawBlankedLine(void)
PicoScanEnd(DrawScanline); PicoScanEnd(DrawScanline);
} }
static int DrawDisplay(int sh, int as) static int DrawDisplay(int sh)
{ {
unsigned char *sprited = &HighLnSpr[DrawScanline][0]; unsigned char *sprited = &HighLnSpr[DrawScanline][0];
struct PicoVideo *pvid=&Pico.video; struct PicoVideo *pvid=&Pico.video;
@ -1374,7 +1369,7 @@ static int DrawDisplay(int sh, int as)
else if (rendstatus & PDRAW_INTERLACE) else if (rendstatus & PDRAW_INTERLACE)
DrawAllSpritesInterlace(1, sh); DrawAllSpritesInterlace(1, sh);
// AS on and have both lo/hi sprites and lo before hi sprites? // AS on and have both lo/hi sprites and lo before hi sprites?
else if (as && (sprited[1] & 0xd0) == 0xd0) else if ((sprited[1] & 0xd0) == 0xd0 && (rendstatus & PDRAW_ACC_SPRITES))
DrawSpritesHiAS(sprited, sh); DrawSpritesHiAS(sprited, sh);
else if (sh && (sprited[1] & SPRL_MAY_HAVE_OP)) else if (sh && (sprited[1] & SPRL_MAY_HAVE_OP))
DrawSpritesSHi(sprited); DrawSpritesSHi(sprited);
@ -1412,19 +1407,18 @@ PICO_INTERNAL void PicoFrameStart(void)
static void PicoLine(void) static void PicoLine(void)
{ {
int sh, as = 0; int sh;
if (skip_next_line>0) { skip_next_line--; return; } // skip rendering lines if (skip_next_line>0) { skip_next_line--; return; } // skip rendering lines
sh=(Pico.video.reg[0xC]&8)>>3; // shadow/hilight? sh=(Pico.video.reg[0xC]&8)>>3; // shadow/hilight?
if (rendstatus & PDRAW_ACC_SPRITES) as|=1; // accurate sprites
if (PicoScanBegin != NULL) if (PicoScanBegin != NULL)
skip_next_line = PicoScanBegin(DrawScanline); skip_next_line = PicoScanBegin(DrawScanline);
// Draw screen: // Draw screen:
BackFill(Pico.video.reg[7], sh|as); BackFill(Pico.video.reg[7], sh);
if (Pico.video.reg[1]&0x40) if (Pico.video.reg[1]&0x40)
DrawDisplay(sh, as); DrawDisplay(sh);
if (FinalizeLine != NULL) if (FinalizeLine != NULL)
FinalizeLine(sh); FinalizeLine(sh);
@ -1534,7 +1528,7 @@ void PicoDrawShowPalette(unsigned short *screen)
HighPal[0x40|i] = (unsigned short)((HighPal[i]>>1)&0x738e); HighPal[0x40|i] = (unsigned short)((HighPal[i]>>1)&0x738e);
for (i = 0x3f; i >= 0; i--) { for (i = 0x3f; i >= 0; i--) {
int t=HighPal[i]&0xe71c;t+=0x4208;if(t&0x20)t|=0x1c;if(t&0x800)t|=0x700;if(t&0x10000)t|=0xe000;t&=0xe71c; int t=HighPal[i]&0xe71c;t+=0x4208;if(t&0x20)t|=0x1c;if(t&0x800)t|=0x700;if(t&0x10000)t|=0xe000;t&=0xe71c;
HighPal[0x80|i]=(unsigned short)t; HighPal[0x80|i] = (unsigned short)t;
} }
screen += 16*320+8; screen += 16*320+8;

View file

@ -1132,11 +1132,11 @@ DrawAllSprites:
ldr r3, =rendstatus ldr r3, =rendstatus
orr r1, r2, r1, lsl #1 orr r1, r2, r1, lsl #1
ldr r12,[r3] ldr r12,[r3]
tst r12,#(PDRAW_ACC_SPRITES|PDRAW_SPRITES_MOVED) tst r12,#(PDRAW_DIRTY_SPRITES|PDRAW_SPRITES_MOVED)
beq das_no_prep beq das_no_prep
stmfd sp!, {r0,r1,lr} stmfd sp!, {r0,r1,lr}
and r0, r12,#PDRAW_DIRTY_SPRITES and r0, r12,#PDRAW_DIRTY_SPRITES
bic r12,r12,#(PDRAW_ACC_SPRITES|PDRAW_SPRITES_MOVED) bic r12,r12,#(PDRAW_DIRTY_SPRITES|PDRAW_SPRITES_MOVED)
str r12,[r3] str r12,[r3]
bl PrepareSprites bl PrepareSprites
ldmfd sp!, {r0,r1,lr} ldmfd sp!, {r0,r1,lr}
@ -1442,7 +1442,7 @@ DrawWindow:
.dwloop_end: .dwloop_end:
ldr r0, =rendstatus ldr r0, =rendstatus
ldr r1, [r0] ldr r1, [r0]
and r6, r6, #2 and r6, r6, #PDRAW_WND_DIFF_PRIO
orr r1, r1, r6 orr r1, r1, r6
str r1, [r0] str r1, [r0]

View file

@ -52,6 +52,7 @@ void emu_textOut8 (int x, int y, const char *text);
void emu_textOut16(int x, int y, const char *text); void emu_textOut16(int x, int y, const char *text);
char *emu_makeRomId(void); char *emu_makeRomId(void);
void emu_findKeyBindCombos(void); void emu_findKeyBindCombos(void);
void emu_forcedFrame(int opts);
extern const char * const keyNames[]; extern const char * const keyNames[];
void emu_prepareDefaultConfig(void); void emu_prepareDefaultConfig(void);

View file

@ -343,13 +343,13 @@ static void SkipFrame(void)
} }
/* forced frame to front buffer */ /* forced frame to front buffer */
void emu_forcedFrame(void) void emu_forcedFrame(int opts)
{ {
int po_old = PicoOpt; int po_old = PicoOpt;
int eo_old = currentConfig.EmuOpt; int eo_old = currentConfig.EmuOpt;
PicoOpt &= ~0x0010; PicoOpt &= ~0x10;
PicoOpt |= 0x4080; // soft_scale | acc_sprites PicoOpt |= opts|POPT_ACC_SPRITES;
currentConfig.EmuOpt |= 0x80; currentConfig.EmuOpt |= 0x80;
if (giz_screen == NULL) if (giz_screen == NULL)

View file

@ -25,7 +25,6 @@ void emu_Init(void);
void emu_Deinit(void); void emu_Deinit(void);
void emu_Loop(void); void emu_Loop(void);
void emu_ResetGame(void); void emu_ResetGame(void);
void emu_forcedFrame(void);
void emu_stateCb(const char *str); void emu_stateCb(const char *str);

View file

@ -578,7 +578,7 @@ static void draw_savestate_bg(int slot)
areaClose(file); areaClose(file);
} }
emu_forcedFrame(); emu_forcedFrame(POPT_EN_SOFTSCALE);
menu_prepare_bg(1); menu_prepare_bg(1);
memcpy(Pico.vram, tmp_vram, sizeof(Pico.vram)); memcpy(Pico.vram, tmp_vram, sizeof(Pico.vram));

View file

@ -141,7 +141,7 @@ void emu_prepareDefaultConfig(void)
{ {
memset(&defaultConfig, 0, sizeof(defaultConfig)); memset(&defaultConfig, 0, sizeof(defaultConfig));
defaultConfig.EmuOpt = 0x1d | 0x00700; // | <- ram_tmng, confirm_save, cd_leds defaultConfig.EmuOpt = 0x1d | 0x00700; // | <- ram_tmng, confirm_save, cd_leds
defaultConfig.s_PicoOpt = 0x0f | 0x20e00; // | <- use_940, cd_pcm, cd_cdda, svp drc defaultConfig.s_PicoOpt = 0x0f | POPT_EXT_FM|POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_SVP_DRC|POPT_ACC_SPRITES;
defaultConfig.s_PsndRate = 44100; defaultConfig.s_PsndRate = 44100;
defaultConfig.s_PicoRegion = 0; // auto defaultConfig.s_PicoRegion = 0; // auto
defaultConfig.s_PicoAutoRgnOrder = 0x184; // US, EU, JP defaultConfig.s_PicoAutoRgnOrder = 0x184; // US, EU, JP
@ -701,13 +701,13 @@ static void SkipFrame(int do_audio)
} }
void emu_forcedFrame(void) void emu_forcedFrame(int opts)
{ {
int po_old = PicoOpt; int po_old = PicoOpt;
int eo_old = currentConfig.EmuOpt; int eo_old = currentConfig.EmuOpt;
PicoOpt &= ~0x0010; PicoOpt &= ~0x10;
PicoOpt |= 0x4080; // soft_scale | acc_sprites PicoOpt |= opts|POPT_ACC_SPRITES; // acc_sprites
currentConfig.EmuOpt |= 0x80; currentConfig.EmuOpt |= 0x80;
//vidResetMode(); //vidResetMode();
@ -1057,7 +1057,7 @@ void emu_Loop(void)
// if in 8bit mode, generate 16bit image for menu background // if in 8bit mode, generate 16bit image for menu background
if ((PicoOpt&0x10) || !(currentConfig.EmuOpt&0x80)) if ((PicoOpt&0x10) || !(currentConfig.EmuOpt&0x80))
emu_forcedFrame(); emu_forcedFrame(POPT_EN_SOFTSCALE);
} }

View file

@ -24,7 +24,6 @@ void emu_Init(void);
void emu_Deinit(void); void emu_Deinit(void);
void emu_Loop(void); void emu_Loop(void);
void emu_ResetGame(void); void emu_ResetGame(void);
void emu_forcedFrame(void);
void osd_text(int x, int y, const char *text); void osd_text(int x, int y, const char *text);

View file

@ -463,7 +463,7 @@ static void draw_frame_debug(void)
if (PicoDrawMask & PDRAW_SPRITES_HI_ON) memcpy(layer_str + 19, "spr_hi", 6); if (PicoDrawMask & PDRAW_SPRITES_HI_ON) memcpy(layer_str + 19, "spr_hi", 6);
memset(gp2x_screen, 0, 320*240*2); memset(gp2x_screen, 0, 320*240*2);
emu_forcedFrame(); emu_forcedFrame(0);
smalltext_out16(4, 232, layer_str, 0xffff); smalltext_out16(4, 232, layer_str, 0xffff);
} }
@ -605,7 +605,7 @@ static void draw_savestate_bg(int slot)
areaClose(file); areaClose(file);
} }
emu_forcedFrame(); emu_forcedFrame(POPT_EN_SOFTSCALE);
menu_prepare_bg(1); menu_prepare_bg(1);
memcpy(Pico.vram, tmp_vram, sizeof(Pico.vram)); memcpy(Pico.vram, tmp_vram, sizeof(Pico.vram));

View file

@ -687,13 +687,13 @@ static void SkipFrame(void)
PicoSkipFrame=0; PicoSkipFrame=0;
} }
void emu_forcedFrame(void) void emu_forcedFrame(int opts)
{ {
int po_old = PicoOpt; int po_old = PicoOpt;
int eo_old = currentConfig.EmuOpt; int eo_old = currentConfig.EmuOpt;
PicoOpt &= ~0x0010; PicoOpt &= ~0x10;
PicoOpt |= 0x4080; // soft_scale | acc_sprites PicoOpt |= opts|POPT_ACC_SPRITES
currentConfig.EmuOpt |= 0x80; currentConfig.EmuOpt |= 0x80;
vidResetMode(); vidResetMode();

View file

@ -25,7 +25,6 @@ void emu_Init(void);
void emu_Deinit(void); void emu_Deinit(void);
void emu_Loop(void); void emu_Loop(void);
void emu_ResetGame(void); void emu_ResetGame(void);
void emu_forcedFrame(void);
void emu_HandleResume(void); void emu_HandleResume(void);
void emu_msg_cb(const char *msg); void emu_msg_cb(const char *msg);