diff --git a/src/emu/video/stvvdp2.c b/src/emu/video/stvvdp2.c index 3c3d9729d4b..95ee49a601e 100644 --- a/src/emu/video/stvvdp2.c +++ b/src/emu/video/stvvdp2.c @@ -5962,11 +5962,10 @@ READ16_MEMBER ( saturn_state::saturn_vdp2_regs_r ) /* latch h/v signals through HV latch*/ if(!STV_VDP2_EXLTEN) { - /* TODO: handle various h/v settings. */ if(!space.debugger_access()) { - m_vdp2.h_count = space.machine().primary_screen->hpos() & 0x3ff; - m_vdp2.v_count = space.machine().primary_screen->vpos() & (STV_VDP2_LSMD == 3 ? 0x7ff : 0x3ff); + m_vdp2.h_count = get_hcounter(); + m_vdp2.v_count = get_vcounter(); /* latch flag */ m_vdp2.exltfg |= 1; } @@ -6253,6 +6252,55 @@ UINT8 saturn_state::get_odd_bit( void ) return machine().primary_screen->frame_number() & 1; } +/* TODO: these needs to be checked via HW tests! */ +int saturn_state::get_hcounter( void ) +{ + int hcount; + + hcount = machine().primary_screen->hpos(); + + switch(STV_VDP2_HRES & 6) + { + /* Normal */ + case 0: + hcount &= 0x1ff; + hcount <<= 1; + break; + /* Hi-Res */ + case 2: + hcount &= 0x3ff; + break; + /* Exclusive Normal*/ + case 4: + hcount &= 0x1ff; + break; + /* Exclusive Hi-Res */ + case 6: + hcount >>= 1; + hcount &= 0x1ff; + break; + } + + return hcount; +} + +int saturn_state::get_vcounter( void ) +{ + int vcount; + + vcount = machine().primary_screen->vpos(); + + /* Exclusive Monitor */ + if(STV_VDP2_HRES & 4) + return vcount & 0x3ff; + + /* Double Density Interlace */ + if((STV_VDP2_LSMD & 3) == 3) + return (vcount & ~1) | (machine().primary_screen->frame_number() & 1); + + return (vcount << 1); // Non-interlace +} + void saturn_state::stv_vdp2_state_save_postload( void ) { UINT8 *gfxdata = m_vdp2.gfx_decode; diff --git a/src/mame/drivers/saturn.c b/src/mame/drivers/saturn.c index c29473201f8..247c8ca42da 100644 --- a/src/mame/drivers/saturn.c +++ b/src/mame/drivers/saturn.c @@ -1532,7 +1532,7 @@ TIMER_DEVICE_CALLBACK_MEMBER(saturn_state::saturn_scanline) //popmessage("%08x %d T0 %d T1 %d %08x",m_scu.ism ^ 0xffffffff,max_y,m_scu_regs[36],m_scu_regs[37],m_scu_regs[38]); - if(scanline == (0)*y_step) + if(scanline == (vblank_line)*y_step) { video_update_vdp1(); diff --git a/src/mame/includes/stv.h b/src/mame/includes/stv.h index 06d55e390a9..04ff831cd8c 100644 --- a/src/mame/includes/stv.h +++ b/src/mame/includes/stv.h @@ -374,6 +374,8 @@ public: UINT8 get_vblank( void ); UINT8 get_hblank( void ); + int get_hcounter( void ); + int get_vcounter( void ); int get_vblank_duration( void ); int get_hblank_duration( void ); int get_pixel_clock( void );