diff --git a/source/genesis.c b/source/genesis.c index b05dd08..15b136b 100644 --- a/source/genesis.c +++ b/source/genesis.c @@ -149,10 +149,6 @@ void gen_reset(uint32 hard_reset) } resetline = -1; -#ifdef NGC - /* register SOFTRESET */ - SYS_SetResetCallback(set_softreset); -#endif /* reset CPUs */ m68k_pulse_reset(); diff --git a/source/gx/gx_input.c b/source/gx/gx_input.c index 44088bc..7d4fc4d 100644 --- a/source/gx/gx_input.c +++ b/source/gx/gx_input.c @@ -157,14 +157,20 @@ static void pad_config(int chan, int max_keys) static void pad_update(s8 chan, u8 i) { - /* get PAD status */ + /* PAD status */ + u16 p = PAD_ButtonsHeld(chan); s8 x = PAD_StickX (chan); s8 y = PAD_StickY (chan); - u16 p = PAD_ButtonsHeld(chan); - - /* Soft RESET */ - if ((p & PAD_TRIGGER_L) && (p & PAD_TRIGGER_Z)) + + if (p & PAD_TRIGGER_Z) { + /* Menu Request */ + ConfigRequested = 1; + return; + } + else if ((p & PAD_TRIGGER_L) && (p & PAD_TRIGGER_Z)) + { + /* Soft RESET */ set_softreset(); } @@ -428,13 +434,19 @@ static void wpad_update(s8 chan, u8 i, u32 exp) /* WPAD data */ WPADData *data = WPAD_Data(chan); - /* WPAD buttons */ + /* WPAD held buttons */ u32 p = data->btns_h; - /* Soft RESET */ - if (((p & WPAD_CLASSIC_BUTTON_PLUS) && (p & WPAD_CLASSIC_BUTTON_MINUS)) || - ((p & WPAD_BUTTON_PLUS) && (p & WPAD_BUTTON_MINUS))) + if ((p & WPAD_BUTTON_HOME) || (p & WPAD_CLASSIC_BUTTON_HOME)) { + /* 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(); } @@ -712,18 +724,11 @@ void gx_input_UpdateEmu(void) WPAD_ScanPads(); #endif - /* Menu Request */ - if (PAD_ButtonsHeld(0) & PAD_TRIGGER_Z) - { - ConfigRequested = 1; - return; - } - #ifdef HW_RVL - if ((WPAD_ButtonsHeld(0) & WPAD_BUTTON_HOME) || (WPAD_ButtonsHeld(0) & WPAD_CLASSIC_BUTTON_HOME)) + if (SYS_ResetButtonDown()) { - ConfigRequested = 1; - return; + /* Soft RESET */ + set_softreset(); } #endif diff --git a/source/gx/gx_input.h b/source/gx/gx_input.h index ead33b6..d342491 100644 --- a/source/gx/gx_input.h +++ b/source/gx/gx_input.h @@ -34,9 +34,6 @@ /* Genesis controller keys */ #define MAX_KEYS 8 -/* Genesis Plus wrapper */ -#define update_input() gx_input_UpdateEmu() - /* Key configuration structure */ typedef struct { diff --git a/source/gx/osd.h b/source/gx/osd.h index fa125e7..c5581b8 100644 --- a/source/gx/osd.h +++ b/source/gx/osd.h @@ -38,6 +38,8 @@ #define VERSION "version 1.3.XG" #endif +#define osd_input_Update() gx_input_UpdateEmu() + /* globals */ extern void error(char *format, ...); extern void ClearGGCodes(); diff --git a/source/render.c b/source/render.c index 39b9bdc..ad248bd 100644 --- a/source/render.c +++ b/source/render.c @@ -982,12 +982,12 @@ static void render_bg(uint32 line, uint32 width) uint32 end = width >> 4; #ifdef LSB_FIRST - uint32 shift = (xscroll >> 16) & 0x0F; - uint32 index = pf_col_mask + 1 - ((xscroll >> 20) & pf_col_mask); + uint32 shift = (xscroll >> 16) & 0x0F; + uint32 index = pf_col_mask + 1 - ((xscroll >> 20) & pf_col_mask); uint32 v_line = (line + ((yscroll >> 16) & 0x3FF)) & pf_row_mask; #else - uint32 shift = (xscroll & 0x0F); - uint32 index = pf_col_mask + 1 - ((xscroll >> 4) & pf_col_mask); + uint32 shift = (xscroll & 0x0F); + uint32 index = pf_col_mask + 1 - ((xscroll >> 4) & pf_col_mask); uint32 v_line = (line + (yscroll & 0x3FF)) & pf_row_mask; #endif @@ -1035,12 +1035,12 @@ static void render_bg(uint32 line, uint32 width) end = clip[0].right; #ifdef LSB_FIRST - shift = (xscroll & 0x0F); - index = pf_col_mask + start + 1 - ((xscroll >> 4) & pf_col_mask); + shift = (xscroll & 0x0F); + index = pf_col_mask + start + 1 - ((xscroll >> 4) & pf_col_mask); v_line = (line + (yscroll & 0x3FF)) & pf_row_mask; #else - shift = (xscroll >> 16) & 0x0F; - index = pf_col_mask + start + 1 - ((xscroll >> 20) & pf_col_mask); + shift = (xscroll >> 16) & 0x0F; + index = pf_col_mask + start + 1 - ((xscroll >> 20) & pf_col_mask); v_line = (line + ((yscroll >> 16) & 0x3FF)) & pf_row_mask; #endif @@ -1103,11 +1103,11 @@ static void render_bg_vs(uint32 line, uint32 width) uint32 end = width >> 4; #ifdef LSB_FIRST - uint32 shift = (xscroll >> 16) & 0x0F; - uint32 index = pf_col_mask + 1 - ((xscroll >> 20) & pf_col_mask); + uint32 shift = (xscroll >> 16) & 0x0F; + uint32 index = pf_col_mask + 1 - ((xscroll >> 20) & pf_col_mask); #else - uint32 shift = (xscroll & 0x0F); - uint32 index = pf_col_mask + 1 - ((xscroll >> 4) & pf_col_mask); + uint32 shift = (xscroll & 0x0F); + uint32 index = pf_col_mask + 1 - ((xscroll >> 4) & pf_col_mask); #endif 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; #else v_line = (line + ((vs[column] >> 16) & 0x3FF)) & pf_row_mask; -#endif +#endif nt = (uint32 *)&vram[ntab + (((v_line >> 3) << pf_shift) & pf_y_mask)]; v_line = (v_line & 7) << 3; @@ -1215,7 +1215,7 @@ static void render_bg_vs(uint32 line, uint32 width) start = clip[1].left; end = clip[1].right; } - + /* Window */ if (w) { @@ -1248,12 +1248,12 @@ static void render_bg_im2(uint32 line, uint32 width, uint32 odd) uint32 end = width >> 4; #ifdef LSB_FIRST - uint32 shift = (xscroll >> 16) & 0x0F; - uint32 index = pf_col_mask + 1 - ((xscroll >> 20) & pf_col_mask); + uint32 shift = (xscroll >> 16) & 0x0F; + uint32 index = pf_col_mask + 1 - ((xscroll >> 20) & pf_col_mask); uint32 v_line = (line + ((yscroll >> 17) & 0x3FF)) & pf_row_mask; #else - uint32 shift = (xscroll & 0x0F); - uint32 index = pf_col_mask + 1 - ((xscroll >> 4) & pf_col_mask); + uint32 shift = (xscroll & 0x0F); + uint32 index = pf_col_mask + 1 - ((xscroll >> 4) & pf_col_mask); uint32 v_line = (line + ((yscroll >> 1) & 0x3FF)) & pf_row_mask; #endif @@ -1299,12 +1299,12 @@ static void render_bg_im2(uint32 line, uint32 width, uint32 odd) end = clip[0].right; #ifdef LSB_FIRST - shift = (xscroll & 0x0F); - index = pf_col_mask + start + 1 - ((xscroll >> 4) & pf_col_mask); + shift = (xscroll & 0x0F); + index = pf_col_mask + start + 1 - ((xscroll >> 4) & pf_col_mask); v_line = (line + ((yscroll >> 1) & 0x3FF)) & pf_row_mask; #else - shift = (xscroll >> 16) & 0x0F; - index = pf_col_mask + start + 1 - ((xscroll >> 20) & pf_col_mask); + shift = (xscroll >> 16) & 0x0F; + index = pf_col_mask + start + 1 - ((xscroll >> 20) & pf_col_mask); v_line = (line + ((yscroll >> 17) & 0x3FF)) & pf_row_mask; #endif diff --git a/source/system.c b/source/system.c index f83fe4c..4bb7eb7 100644 --- a/source/system.c +++ b/source/system.c @@ -257,7 +257,7 @@ int system_frame (int do_skip) { if (!gen_running) { - update_input(); + osd_input_Update(); return 0; } @@ -318,10 +318,6 @@ int system_frame (int do_skip) /* Soft Reset ? */ if (line == reset) { -#ifdef NGC - /* wait for RESET button to be released */ - while (SYS_ResetButtonDown()); -#endif /* Pro Action Replay (switch at "Trainer" position) */ if (config.lock_on == TYPE_AR) datel_reset(0); @@ -343,10 +339,11 @@ int system_frame (int do_skip) if ((line != 0) || (h_counter == 0)) aim_m68k += 36; } - /* 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 */ - /* as a result, current line is shortened */ - /* fix Lotus 1, Lotus 2 RECS, Striker, Zero the Kamikaze Squirell */ + /* HINT will be triggered on next line, approx. 36 cycles before VDP starts line rendering */ + /* during this period, any VRAM or VSRAM writes should NOT be taken in account before next line */ + /* as a result, line is rendered immediately after HINT and current line is shortened */ + /* 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; /* update DMA timings */ @@ -359,7 +356,7 @@ int system_frame (int do_skip) if ((line < end_line) && (!do_skip)) render_line(line, 1); /* update inputs (doing this here fix Warriors of Eternal Sun) */ - update_input(); + osd_input_Update(); /* set VBLANK flag */ status |= 0x08; diff --git a/source/vdp.c b/source/vdp.c index 45b24b8..4215630 100644 --- a/source/vdp.c +++ b/source/vdp.c @@ -430,8 +430,8 @@ unsigned int vdp_ctrl_r(void) /* display OFF: VBLANK flag is set */ if (!(reg[1] & 0x40)) temp |= 0x8; - /* HBLANK flag (Sonic 3 and Sonic 2 "VS Modes", Lemmings 2) */ - if ((count_m68k <= (line_m68k + 84)) || (count_m68k > (line_m68k + m68cycles_per_line))) temp |= 0x4; + /* 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 - 36))) temp |= 0x4; /* clear pending flag */ pending = 0; @@ -616,6 +616,13 @@ static inline void data_w(unsigned int data) *p = data; if (index) color_update (index, *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; } @@ -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; } - /* Display activated/blanked during Horizontal Blanking */ + /* Display enabled/blanked during "Horizontal Blanking" */ if (((d&0x40) != (reg[1]&0x40)) && !(status & 8)) { if (count_m68k <= (hint_m68k + 120)) { - /* Redraw the current line : - - Legend of Galahad, Lemmings 2, Nigel Mansell's World Championship Racing (set display OFF) - - Deadly Moves aka Power Athlete (set display ON) + /* Fixes the following games : + - Legend of Galahad, Lemmings 2, Nigel Mansell's World Championship Racing (display OFF) + - 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; 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 */ 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; remap_buffer(v_counter,bitmap.viewport.w + 2*bitmap.viewport.x); }