Fixed SMPC change clock behaviour, fixes 2 credits at start-up for various ST-V games [Angelo Salese]

This commit is contained in:
Angelo Salese 2013-02-15 14:42:16 +00:00
parent 1b18ce13d6
commit 32edfb1081
5 changed files with 38 additions and 40 deletions

View File

@ -155,25 +155,6 @@ TODO:
#define LOG_SMPC 0
#define LOG_PAD_CMD 0
#if 0
/* TODO: move this into video functions */
static int vblank_line(running_machine &machine)
{
saturn_state *state = machine.driver_data<saturn_state>();
int max_y = machine.primary_screen->height();
int y_step,vblank_line;
y_step = 2;
if((max_y == 263 && state->m_vdp2.pal == 0) || (max_y == 313 && state->m_vdp2.pal == 1))
y_step = 1;
vblank_line = (state->m_vdp2.pal) ? 288 : 240;
return vblank_line*y_step;
}
#endif
/********************************************
*
@ -273,9 +254,12 @@ static TIMER_CALLBACK( smpc_change_clock )
state->m_vdp2.dotsel = param ^ 1;
state->stv_vdp2_dynamic_res_change();
state->m_maincpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
if(!state->m_NMI_reset)
state->m_maincpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE);
state->m_slave->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
state->m_slave->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
state->m_audiocpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
/* put issued command in OREG31 */
state->m_smpc.OREG[31] = 0x0e + param;
@ -721,11 +705,16 @@ static void smpc_comreg_exec(address_space &space, UINT8 data, UINT8 is_stv)
if(LOG_SMPC) printf ("SMPC: Change Clock to %s (%d %d)\n",data & 1 ? "320" : "352",space.machine().primary_screen->hpos(),space.machine().primary_screen->vpos());
/* on ST-V timing of this is pretty fussy, you get 2 credits at start-up otherwise
sokyugurentai threshold is 74 lines
shanhigw threshold is 90 lines
I assume that it needs ~100 lines, so 6666,(6) usecs. Obviously needs HW tests ... */
My current theory is that SMPC first stops all CPUs until it executes the whole snippet for this,
and restarts them when the screen is again ready for use. I really don't think that the system
can do an usable mid-frame clock switching anyway.
*/
space.machine().scheduler().timer_set(attotime::from_usec(6666), FUNC(smpc_change_clock),data & 1);
state->m_maincpu->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
state->m_slave->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
state->m_audiocpu->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
space.machine().scheduler().timer_set(space.machine().primary_screen->time_until_pos(state->get_vblank_start_position()*state->get_ystep_count(), 0), FUNC(smpc_change_clock),data & 1);
break;
/*"Interrupt Back"*/
case 0x10:

View File

@ -6252,6 +6252,28 @@ UINT8 saturn_state::get_odd_bit( void )
return machine().primary_screen->frame_number() & 1;
}
int saturn_state::get_vblank_start_position( void )
{
int vblank_line;
vblank_line = (m_vdp2.pal) ? 288 : 240;
return vblank_line;
}
int saturn_state::get_ystep_count( void )
{
int max_y = machine().primary_screen->height();
int y_step;
y_step = 2;
if((max_y == 263 && m_vdp2.pal == 0) || (max_y == 313 && m_vdp2.pal == 1))
y_step = 1;
return y_step;
}
/* TODO: these needs to be checked via HW tests! */
int saturn_state::get_hcounter( void )
{

View File

@ -1520,15 +1520,10 @@ TODO:
TIMER_DEVICE_CALLBACK_MEMBER(saturn_state::saturn_scanline)
{
int scanline = param;
int max_y = machine().primary_screen->height();
int y_step,vblank_line;
y_step = 2;
if((max_y == 263 && m_vdp2.pal == 0) || (max_y == 313 && m_vdp2.pal == 1))
y_step = 1;
vblank_line = (m_vdp2.pal) ? 288 : 240;
vblank_line = get_vblank_start_position();
y_step = get_ystep_count();
//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]);

View File

@ -658,20 +658,11 @@ bp 6001d22 (60ffef0)
*/
READ32_MEMBER(saturn_state::astrass_hack_r)
{
if(space.device().safe_pc() == 0x60011ba) return 0x00000000;
return m_workram_h[0x000770/4];
}
DRIVER_INIT_MEMBER(saturn_state,astrass)
{
sh2drc_add_pcflush(machine().device("maincpu"), 0x60011ba);
sh2drc_add_pcflush(machine().device("maincpu"), 0x605b9da);
machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x06000770, 0x06000773, read32_delegate(FUNC(saturn_state::astrass_hack_r),this));
install_astrass_protection(machine());
DRIVER_INIT_CALL(stv);

View File

@ -151,7 +151,6 @@ public:
DECLARE_WRITE32_MEMBER(magzun_ioga_w32);
DECLARE_READ32_MEMBER(magzun_hef_hack_r);
DECLARE_READ32_MEMBER(magzun_rx_hack_r);
DECLARE_READ32_MEMBER(astrass_hack_r);
DECLARE_INPUT_CHANGED_MEMBER(key_stroke);
DECLARE_INPUT_CHANGED_MEMBER(nmi_reset);
DECLARE_INPUT_CHANGED_MEMBER(tray_open);
@ -381,6 +380,8 @@ public:
int get_pixel_clock( void );
UINT8 get_odd_bit( void );
void stv_vdp2_dynamic_res_change( void );
int get_vblank_start_position( void );
int get_ystep_count( void );
void refresh_palette_data( void );
int stv_vdp2_window_process(int x,int y);