improved HBLANK flag occurence timing (fixes Mega Turrican Sky level)

improved emulation of CRAM writes during HBLANK
improved Wii RESET button behavior ("true" MD soft-reset)
This commit is contained in:
ekeeke31 2009-09-30 17:11:24 +00:00
parent cccd71e612
commit 45756f6b14
7 changed files with 73 additions and 65 deletions

View File

@ -149,10 +149,6 @@ void gen_reset(uint32 hard_reset)
} }
resetline = -1; resetline = -1;
#ifdef NGC
/* register SOFTRESET */
SYS_SetResetCallback(set_softreset);
#endif
/* reset CPUs */ /* reset CPUs */
m68k_pulse_reset(); m68k_pulse_reset();

View File

@ -157,14 +157,20 @@ static void pad_config(int chan, int max_keys)
static void pad_update(s8 chan, u8 i) static void pad_update(s8 chan, u8 i)
{ {
/* get PAD status */ /* PAD status */
u16 p = PAD_ButtonsHeld(chan);
s8 x = PAD_StickX (chan); s8 x = PAD_StickX (chan);
s8 y = PAD_StickY (chan); s8 y = PAD_StickY (chan);
u16 p = PAD_ButtonsHeld(chan);
if (p & PAD_TRIGGER_Z)
/* Soft RESET */
if ((p & PAD_TRIGGER_L) && (p & PAD_TRIGGER_Z))
{ {
/* Menu Request */
ConfigRequested = 1;
return;
}
else if ((p & PAD_TRIGGER_L) && (p & PAD_TRIGGER_Z))
{
/* Soft RESET */
set_softreset(); set_softreset();
} }
@ -428,13 +434,19 @@ static void wpad_update(s8 chan, u8 i, u32 exp)
/* WPAD data */ /* WPAD data */
WPADData *data = WPAD_Data(chan); WPADData *data = WPAD_Data(chan);
/* WPAD buttons */ /* WPAD held buttons */
u32 p = data->btns_h; u32 p = data->btns_h;
/* Soft RESET */ if ((p & WPAD_BUTTON_HOME) || (p & WPAD_CLASSIC_BUTTON_HOME))
if (((p & WPAD_CLASSIC_BUTTON_PLUS) && (p & WPAD_CLASSIC_BUTTON_MINUS)) ||
((p & WPAD_BUTTON_PLUS) && (p & WPAD_BUTTON_MINUS)))
{ {
/* Menu Request */
ConfigRequested = 1;
return;
}
else if (((p & WPAD_BUTTON_PLUS) && (p & WPAD_BUTTON_MINUS)) ||
((p & WPAD_CLASSIC_BUTTON_PLUS) && (p & WPAD_CLASSIC_BUTTON_MINUS)))
{
/* Soft RESET */
set_softreset(); set_softreset();
} }
@ -712,18 +724,11 @@ void gx_input_UpdateEmu(void)
WPAD_ScanPads(); WPAD_ScanPads();
#endif #endif
/* Menu Request */
if (PAD_ButtonsHeld(0) & PAD_TRIGGER_Z)
{
ConfigRequested = 1;
return;
}
#ifdef HW_RVL #ifdef HW_RVL
if ((WPAD_ButtonsHeld(0) & WPAD_BUTTON_HOME) || (WPAD_ButtonsHeld(0) & WPAD_CLASSIC_BUTTON_HOME)) if (SYS_ResetButtonDown())
{ {
ConfigRequested = 1; /* Soft RESET */
return; set_softreset();
} }
#endif #endif

View File

@ -34,9 +34,6 @@
/* Genesis controller keys */ /* Genesis controller keys */
#define MAX_KEYS 8 #define MAX_KEYS 8
/* Genesis Plus wrapper */
#define update_input() gx_input_UpdateEmu()
/* Key configuration structure */ /* Key configuration structure */
typedef struct typedef struct
{ {

View File

@ -38,6 +38,8 @@
#define VERSION "version 1.3.XG" #define VERSION "version 1.3.XG"
#endif #endif
#define osd_input_Update() gx_input_UpdateEmu()
/* globals */ /* globals */
extern void error(char *format, ...); extern void error(char *format, ...);
extern void ClearGGCodes(); extern void ClearGGCodes();

View File

@ -982,12 +982,12 @@ static void render_bg(uint32 line, uint32 width)
uint32 end = width >> 4; uint32 end = width >> 4;
#ifdef LSB_FIRST #ifdef LSB_FIRST
uint32 shift = (xscroll >> 16) & 0x0F; uint32 shift = (xscroll >> 16) & 0x0F;
uint32 index = pf_col_mask + 1 - ((xscroll >> 20) & pf_col_mask); uint32 index = pf_col_mask + 1 - ((xscroll >> 20) & pf_col_mask);
uint32 v_line = (line + ((yscroll >> 16) & 0x3FF)) & pf_row_mask; uint32 v_line = (line + ((yscroll >> 16) & 0x3FF)) & pf_row_mask;
#else #else
uint32 shift = (xscroll & 0x0F); uint32 shift = (xscroll & 0x0F);
uint32 index = pf_col_mask + 1 - ((xscroll >> 4) & pf_col_mask); uint32 index = pf_col_mask + 1 - ((xscroll >> 4) & pf_col_mask);
uint32 v_line = (line + (yscroll & 0x3FF)) & pf_row_mask; uint32 v_line = (line + (yscroll & 0x3FF)) & pf_row_mask;
#endif #endif
@ -1035,12 +1035,12 @@ static void render_bg(uint32 line, uint32 width)
end = clip[0].right; end = clip[0].right;
#ifdef LSB_FIRST #ifdef LSB_FIRST
shift = (xscroll & 0x0F); shift = (xscroll & 0x0F);
index = pf_col_mask + start + 1 - ((xscroll >> 4) & pf_col_mask); index = pf_col_mask + start + 1 - ((xscroll >> 4) & pf_col_mask);
v_line = (line + (yscroll & 0x3FF)) & pf_row_mask; v_line = (line + (yscroll & 0x3FF)) & pf_row_mask;
#else #else
shift = (xscroll >> 16) & 0x0F; shift = (xscroll >> 16) & 0x0F;
index = pf_col_mask + start + 1 - ((xscroll >> 20) & pf_col_mask); index = pf_col_mask + start + 1 - ((xscroll >> 20) & pf_col_mask);
v_line = (line + ((yscroll >> 16) & 0x3FF)) & pf_row_mask; v_line = (line + ((yscroll >> 16) & 0x3FF)) & pf_row_mask;
#endif #endif
@ -1103,11 +1103,11 @@ static void render_bg_vs(uint32 line, uint32 width)
uint32 end = width >> 4; uint32 end = width >> 4;
#ifdef LSB_FIRST #ifdef LSB_FIRST
uint32 shift = (xscroll >> 16) & 0x0F; uint32 shift = (xscroll >> 16) & 0x0F;
uint32 index = pf_col_mask + 1 - ((xscroll >> 20) & pf_col_mask); uint32 index = pf_col_mask + 1 - ((xscroll >> 20) & pf_col_mask);
#else #else
uint32 shift = (xscroll & 0x0F); uint32 shift = (xscroll & 0x0F);
uint32 index = pf_col_mask + 1 - ((xscroll >> 4) & pf_col_mask); uint32 index = pf_col_mask + 1 - ((xscroll >> 4) & pf_col_mask);
#endif #endif
uint32 v_line, *nt; uint32 v_line, *nt;
@ -1203,7 +1203,7 @@ static void render_bg_vs(uint32 line, uint32 width)
v_line = (line + (vs[column] & 0x3FF)) & pf_row_mask; v_line = (line + (vs[column] & 0x3FF)) & pf_row_mask;
#else #else
v_line = (line + ((vs[column] >> 16) & 0x3FF)) & pf_row_mask; v_line = (line + ((vs[column] >> 16) & 0x3FF)) & pf_row_mask;
#endif #endif
nt = (uint32 *)&vram[ntab + (((v_line >> 3) << pf_shift) & pf_y_mask)]; nt = (uint32 *)&vram[ntab + (((v_line >> 3) << pf_shift) & pf_y_mask)];
v_line = (v_line & 7) << 3; v_line = (v_line & 7) << 3;
@ -1215,7 +1215,7 @@ static void render_bg_vs(uint32 line, uint32 width)
start = clip[1].left; start = clip[1].left;
end = clip[1].right; end = clip[1].right;
} }
/* Window */ /* Window */
if (w) if (w)
{ {
@ -1248,12 +1248,12 @@ static void render_bg_im2(uint32 line, uint32 width, uint32 odd)
uint32 end = width >> 4; uint32 end = width >> 4;
#ifdef LSB_FIRST #ifdef LSB_FIRST
uint32 shift = (xscroll >> 16) & 0x0F; uint32 shift = (xscroll >> 16) & 0x0F;
uint32 index = pf_col_mask + 1 - ((xscroll >> 20) & pf_col_mask); uint32 index = pf_col_mask + 1 - ((xscroll >> 20) & pf_col_mask);
uint32 v_line = (line + ((yscroll >> 17) & 0x3FF)) & pf_row_mask; uint32 v_line = (line + ((yscroll >> 17) & 0x3FF)) & pf_row_mask;
#else #else
uint32 shift = (xscroll & 0x0F); uint32 shift = (xscroll & 0x0F);
uint32 index = pf_col_mask + 1 - ((xscroll >> 4) & pf_col_mask); uint32 index = pf_col_mask + 1 - ((xscroll >> 4) & pf_col_mask);
uint32 v_line = (line + ((yscroll >> 1) & 0x3FF)) & pf_row_mask; uint32 v_line = (line + ((yscroll >> 1) & 0x3FF)) & pf_row_mask;
#endif #endif
@ -1299,12 +1299,12 @@ static void render_bg_im2(uint32 line, uint32 width, uint32 odd)
end = clip[0].right; end = clip[0].right;
#ifdef LSB_FIRST #ifdef LSB_FIRST
shift = (xscroll & 0x0F); shift = (xscroll & 0x0F);
index = pf_col_mask + start + 1 - ((xscroll >> 4) & pf_col_mask); index = pf_col_mask + start + 1 - ((xscroll >> 4) & pf_col_mask);
v_line = (line + ((yscroll >> 1) & 0x3FF)) & pf_row_mask; v_line = (line + ((yscroll >> 1) & 0x3FF)) & pf_row_mask;
#else #else
shift = (xscroll >> 16) & 0x0F; shift = (xscroll >> 16) & 0x0F;
index = pf_col_mask + start + 1 - ((xscroll >> 20) & pf_col_mask); index = pf_col_mask + start + 1 - ((xscroll >> 20) & pf_col_mask);
v_line = (line + ((yscroll >> 17) & 0x3FF)) & pf_row_mask; v_line = (line + ((yscroll >> 17) & 0x3FF)) & pf_row_mask;
#endif #endif

View File

@ -257,7 +257,7 @@ int system_frame (int do_skip)
{ {
if (!gen_running) if (!gen_running)
{ {
update_input(); osd_input_Update();
return 0; return 0;
} }
@ -318,10 +318,6 @@ int system_frame (int do_skip)
/* Soft Reset ? */ /* Soft Reset ? */
if (line == reset) if (line == reset)
{ {
#ifdef NGC
/* wait for RESET button to be released */
while (SYS_ResetButtonDown());
#endif
/* Pro Action Replay (switch at "Trainer" position) */ /* Pro Action Replay (switch at "Trainer" position) */
if (config.lock_on == TYPE_AR) if (config.lock_on == TYPE_AR)
datel_reset(0); datel_reset(0);
@ -343,10 +339,11 @@ int system_frame (int do_skip)
if ((line != 0) || (h_counter == 0)) aim_m68k += 36; if ((line != 0) || (h_counter == 0)) aim_m68k += 36;
} }
/* HINT will be triggered on next line, approx. 36 cycles before VDP starts line rendering */ /* HINT will be triggered on next line, approx. 36 cycles before VDP starts line rendering */
/* during this period, any VRAM/CRAM/VSRAM writes should NOT be taken in account before next line */ /* during this period, any VRAM or VSRAM writes should NOT be taken in account before next line */
/* as a result, current line is shortened */ /* as a result, line is rendered immediately after HINT and current line is shortened */
/* fix Lotus 1, Lotus 2 RECS, Striker, Zero the Kamikaze Squirell */ /* CRAM and VDP register writes that could occur during HBLANK are handled separately */
/* fix Lotus 1, Lotus 2 RECS, Striker, Skitchin, Zero the Kamikaze Squirell */
if ((line < vdp_height) && (h_counter == 0)) aim_m68k -= 36; if ((line < vdp_height) && (h_counter == 0)) aim_m68k -= 36;
/* update DMA timings */ /* update DMA timings */
@ -359,7 +356,7 @@ int system_frame (int do_skip)
if ((line < end_line) && (!do_skip)) render_line(line, 1); if ((line < end_line) && (!do_skip)) render_line(line, 1);
/* update inputs (doing this here fix Warriors of Eternal Sun) */ /* update inputs (doing this here fix Warriors of Eternal Sun) */
update_input(); osd_input_Update();
/* set VBLANK flag */ /* set VBLANK flag */
status |= 0x08; status |= 0x08;

View File

@ -430,8 +430,8 @@ unsigned int vdp_ctrl_r(void)
/* display OFF: VBLANK flag is set */ /* display OFF: VBLANK flag is set */
if (!(reg[1] & 0x40)) temp |= 0x8; if (!(reg[1] & 0x40)) temp |= 0x8;
/* HBLANK flag (Sonic 3 and Sonic 2 "VS Modes", Lemmings 2) */ /* HBLANK flag (Sonic 3 and Sonic 2 "VS Modes", Lemmings 2, Mega Turrican) */
if ((count_m68k <= (line_m68k + 84)) || (count_m68k > (line_m68k + m68cycles_per_line))) temp |= 0x4; if ((count_m68k <= (line_m68k + 84)) || (count_m68k > (line_m68k + m68cycles_per_line - 36))) temp |= 0x4;
/* clear pending flag */ /* clear pending flag */
pending = 0; pending = 0;
@ -616,6 +616,13 @@ static inline void data_w(unsigned int data)
*p = data; *p = data;
if (index) color_update (index, *p); if (index) color_update (index, *p);
if (border == index) color_update (0x00, *p); if (border == index) color_update (0x00, *p);
/* CRAM modified during HBLANK */
if (!(status & 8) && (reg[1]&0x40) && (count_m68k <= (line_m68k + 84)))
{
/* remap current line (Striker) */
remap_buffer(v_counter,bitmap.viewport.w + 2*bitmap.viewport.x);
}
} }
break; break;
} }
@ -691,15 +698,19 @@ static inline void reg_w(unsigned int r, unsigned int d)
if (vdp_pal) vctab = (d & 8) ? vc_pal_240 : vc_pal_224; if (vdp_pal) vctab = (d & 8) ? vc_pal_240 : vc_pal_224;
} }
/* Display activated/blanked during Horizontal Blanking */ /* Display enabled/blanked during "Horizontal Blanking" */
if (((d&0x40) != (reg[1]&0x40)) && !(status & 8)) if (((d&0x40) != (reg[1]&0x40)) && !(status & 8))
{ {
if (count_m68k <= (hint_m68k + 120)) if (count_m68k <= (hint_m68k + 120))
{ {
/* Redraw the current line : /* Fixes the following games :
- Legend of Galahad, Lemmings 2, Nigel Mansell's World Championship Racing (set display OFF) - Legend of Galahad, Lemmings 2, Nigel Mansell's World Championship Racing (display OFF)
- Deadly Moves aka Power Athlete (set display ON) - Deadly Moves, Power Athlete (display ON)
*/ */
/* NB: This is not entirely correct since we are a little too tolerant with the HBLANK period limits
while still redrawing the whole line. This is done because some games appear to write this
register outside HBLANK: on real hardware, the line would appear partially blanked.
*/
reg[1] = d; reg[1] = d;
render_line(v_counter, 0); render_line(v_counter, 0);
} }
@ -745,7 +756,7 @@ static inline void reg_w(unsigned int r, unsigned int d)
/* background color modified during Horizontal Blanking */ /* background color modified during Horizontal Blanking */
if (!(status & 8) && (count_m68k <= (line_m68k + 84))) if (!(status & 8) && (count_m68k <= (line_m68k + 84)))
{ {
/* remap current line (see Road Rash I,II,III) */ /* remap entire line (see Road Rash I,II,III) */
reg[7] = d; reg[7] = d;
remap_buffer(v_counter,bitmap.viewport.w + 2*bitmap.viewport.x); remap_buffer(v_counter,bitmap.viewport.w + 2*bitmap.viewport.x);
} }