Cleaned up comreg execute function, stateized a bunch of IOGA variables (in preparation of the major overhaul of that function)

This commit is contained in:
Angelo Salese 2011-08-18 01:21:02 +00:00
parent 9a878722a2
commit 8ba9cd7cd2
4 changed files with 334 additions and 363 deletions

View File

@ -131,216 +131,6 @@ static void scu_dma_indirect(address_space *space, UINT8 dma_ch); /*DMA level 0
/**************************************************************************************/
/*
I/O overview:
PORT-A 1st player inputs
PORT-B 2nd player inputs
PORT-C system input
PORT-D system output
PORT-E I/O 1
PORT-F I/O 2
PORT-G I/O 3
PORT-AD AD-Stick inputs?(Fake for now...)
SERIAL COM
offsets:
0h PORT-A
0l PORT-B
1h PORT-C
1l PORT-D
2h PORT-E
2l PORT-F (extra button layout)
3h PORT-G
3l
4h PORT-SEL
4l
5h SERIAL COM WRITE
5l
6h SERIAL COM READ
6l
7h
7l PORT-AD
*/
static const UINT8 port_ad[] =
{
0xcc,0xb2,0x99,0x7f,0x66,0x4c,0x33,0x19
};
static UINT8 port_sel,mux_data;
static int port_i;
static READ32_HANDLER ( stv_io_r32 )
{
saturn_state *state = space->machine().driver_data<saturn_state>();
// if(LOG_IOGA) logerror("(PC=%08X): I/O r %08X & %08X\n", cpu_get_pc(&space->device()), offset*4, mem_mask);
// popmessage("SEL: %02x MUX: %02x OFF: %02x",port_sel,mux_data,offset*4);
// printf("(PC=%08X): I/O r %08X & %08X\n", cpu_get_pc(&space->device()), offset*4, mem_mask);
switch(offset)
{
case 0x00/4:
switch(port_sel)
{
case 0x77: return 0xff000000|(input_port_read(space->machine(), "P1") << 16) |0x0000ff00|(input_port_read(space->machine(), "P2"));
case 0x67:
{
switch(mux_data)
{
/*Mahjong panel interface,bit wise(ACTIVE LOW)*/
case 0xfe: return 0xff000000 | (input_port_read_safe(space->machine(), "KEY0", 0) << 16) | 0x0000ff00 | (input_port_read_safe(space->machine(), "KEY5", 0));
case 0xfd: return 0xff000000 | (input_port_read_safe(space->machine(), "KEY1", 0) << 16) | 0x0000ff00 | (input_port_read_safe(space->machine(), "KEY6", 0));
case 0xfb: return 0xff000000 | (input_port_read_safe(space->machine(), "KEY2", 0) << 16) | 0x0000ff00 | (input_port_read_safe(space->machine(), "KEY7", 0));
case 0xf7: return 0xff000000 | (input_port_read_safe(space->machine(), "KEY3", 0) << 16) | 0x0000ff00 | (input_port_read_safe(space->machine(), "KEY8", 0));
case 0xef: return 0xff000000 | (input_port_read_safe(space->machine(), "KEY4", 0) << 16) | 0x0000ff00 | (input_port_read_safe(space->machine(), "KEY9", 0));
/*Joystick panel*/
default:
//popmessage("%02x MUX DATA",mux_data);
return (input_port_read(space->machine(), "P1") << 16) | (input_port_read(space->machine(), "P2"));
}
}
case 0x47:
{
if ( strcmp(space->machine().system().name,"critcrsh") == 0 )
{
int data1 = 0, data2 = 0;
/* Critter Crusher */
data1 = input_port_read(space->machine(), "LIGHTX");
data1 = BITSWAP8(data1, 2, 3, 0, 1, 6, 7, 5, 4) & 0xf3;
data1 |= (input_port_read(space->machine(), "P1") & 1) ? 0x0 : 0x4;
data2 = input_port_read(space->machine(), "LIGHTY");
data2 = BITSWAP8(data2, 2, 3, 0, 1, 6, 7, 5, 4) & 0xf3;
data2 |= (input_port_read(space->machine(), "P1") & 1) ? 0x0 : 0x4;
return 0xff000000 | data1 << 16 | 0x0000ff00 | data2;
}
}
//default:
//case 0x40: return space->machine().rand();
default:
//popmessage("%02x PORT SEL",port_sel);
return (input_port_read(space->machine(), "P1") << 16) | (input_port_read(space->machine(), "P2"));
}
case 0x04/4:
if ( strcmp(space->machine().system().name,"critcrsh") == 0 )
return ((input_port_read(space->machine(), "SYSTEM") << 16) & ((input_port_read(space->machine(), "P1") & 1) ? 0xffef0000 : 0xffff0000)) | (state->m_ioga[1]);
else
return (input_port_read(space->machine(), "SYSTEM") << 16) | (state->m_ioga[1]);
case 0x08/4:
switch(port_sel)
{
case 0x77: return (input_port_read(space->machine(), "UNUSED") << 16) | (input_port_read(space->machine(), "EXTRA"));
case 0x67: return 0xffffffff;/**/
case 0x20: return 0xffff0000 | (state->m_ioga[2] & 0xffff);
case 0x10: return ((state->m_ioga[2] & 0xffff) << 16) | 0xffff;
case 0x60: return 0xffffffff;/**/
default:
return 0xffffffff;
}
case 0x0c/4:
switch(port_sel)
{
case 0x60: return ((state->m_ioga[2] & 0xffff) << 16) | 0xffff;
default:
//popmessage("offs: 3 %02x",port_sel);
return 0xffffffff;
}
//case 0x10/4:
case 0x14/4:
switch(port_sel)
{
case 0x77:
{
//popmessage("(PC=%06x) offs 5 %04x %02x",cpu_get_pc(&space->device()),port_sel,((state->m_ioga[5] & 0xff0000) >> 16));
logerror("(PC=%06x) offs 5 %04x %02x\n",cpu_get_pc(&space->device()),port_sel,((state->m_ioga[5] & 0xff0000) >> 16));
//stv_m_workram_h[0x8e830/4] = ((state->m_ioga[5] & 0xff0000) >> 16) ^ 0x3;
//stv_m_workram_h[0x8e834/4] = ((state->m_ioga[5] & 0xff0000) >> 16) ^ 0x3;
return (state->m_ioga[5] & 0xff0000) >> 16;//stv_m_workram_h[0x8e830/4];//sound board data
}
default: return 0xffffffff;
}
case 0x18/4:
switch(port_sel)
{
case 0x60: return state->m_ioga[5];
case 0x77:
{
//popmessage("(PC=%06x) offs 6 %04x %02x",cpu_get_pc(&space->device()),port_sel,((state->m_ioga[5] & 0xff0000) >> 16));
logerror("(PC=%06x) offs 6 %04x %02x\n",cpu_get_pc(&space->device()),port_sel,((state->m_ioga[5] & 0xff0000) >> 16));
return 0;//sound board status,non-zero = processing
}
default:
//popmessage("offs: 6 %02x",port_sel);
return 0xffffffff;
}
case 0x1c/4:
if(LOG_IOGA) logerror("(PC %s=%06x) Warning: READ from PORT_AD\n", space->device().tag(), cpu_get_pc(&space->device()));
popmessage("Read from PORT_AD");
port_i++;
return port_ad[port_i & 7];
default:
return state->m_ioga[offset];
}
}
static WRITE32_HANDLER ( stv_io_w32 )
{
saturn_state *state = space->machine().driver_data<saturn_state>();
// if(LOG_IOGA) logerror("(PC=%08X): I/O w %08X = %08X & %08X\n", cpu_get_pc(&space->device()), offset*4, data, mem_mask);
// if(data != 0x0c)
// printf("(PC=%08X): I/O w %08X = %08X & %08X\n", cpu_get_pc(&space->device()), offset*4, data, mem_mask);
switch(offset)
{
case 0x04/4:
if(ACCESSING_BITS_0_7)
{
/*Why does the BIOS tests these as ACTIVE HIGH? A program bug?*/
state->m_ioga[1] = (data) & 0xff;
coin_counter_w(space->machine(), 0,~data & 0x01);
coin_counter_w(space->machine(), 1,~data & 0x02);
coin_lockout_w(space->machine(), 0,~data & 0x04);
coin_lockout_w(space->machine(), 1,~data & 0x08);
/*
other bits reserved
*/
}
break;
case 0x08/4:
if(ACCESSING_BITS_16_23)
{
state->m_ioga[2] = data >> 16;
mux_data = state->m_ioga[2];
}
else if(ACCESSING_BITS_0_7)
state->m_ioga[2] = data;
break;
case 0x0c/4:
if(ACCESSING_BITS_16_23)
state->m_ioga[3] = data;
break;
case 0x10/4:
if(ACCESSING_BITS_16_23)
port_sel = (data & 0xffff0000) >> 16;
break;
case 0x14/4:
if(ACCESSING_BITS_16_23)
state->m_ioga[5] = data;
break;
//case 0x18/4:
case 0x1c/4:
//technical bowling tests here
if(ACCESSING_BITS_16_23)
state->m_ioga[7] = data;
break;
}
}
/*
SCU Handling
@ -1928,8 +1718,8 @@ static MACHINE_START( stv )
state_save_register_global(machine, state->m_smpc.EXLE2);
state_save_register_global(machine, state->m_smpc.PDR1);
state_save_register_global(machine, state->m_smpc.PDR2);
state_save_register_global(machine, port_sel);
state_save_register_global(machine, mux_data);
state_save_register_global(machine, state->m_port_sel);
state_save_register_global(machine, state->m_mux_data);
state_save_register_global(machine, scsp_last_line);
stv_register_protection_savestates(machine); // machine/stvprot.c
@ -1971,7 +1761,7 @@ static MACHINE_START( saturn )
state_save_register_global(machine, state->m_smpc.EXLE2);
state_save_register_global(machine, state->m_smpc.PDR1);
state_save_register_global(machine, state->m_smpc.PDR2);
// state_save_register_global(machine, port_sel);
// state_save_register_global(machine, state->m_port_sel);
// state_save_register_global(machine, mux_data);
state_save_register_global(machine, scsp_last_line);
state_save_register_global(machine, state->m_smpc.intback_stage);
@ -2283,8 +2073,8 @@ static MACHINE_RESET( stv )
state->m_en_68k = 0;
state->m_NMI_reset = 0;
port_sel = mux_data = 0;
port_i = -1;
state->m_port_sel = state->m_mux_data = 0;
state->m_port_i = -1;
machine.device("maincpu")->set_unscaled_clock(MASTER_CLOCK_320/2);
machine.device("slave")->set_unscaled_clock(MASTER_CLOCK_320/2);

View File

@ -13,6 +13,213 @@
#define FIRST_SPEEDUP_SLOT (2) // in case we remove/alter the BIOS speedups later
/*
I/O overview:
PORT-A 1st player inputs
PORT-B 2nd player inputs
PORT-C system input
PORT-D system output
PORT-E I/O 1
PORT-F I/O 2
PORT-G I/O 3
PORT-AD AD-Stick inputs?(Fake for now...)
SERIAL COM
offsets:
0h PORT-A
0l PORT-B
1h PORT-C
1l PORT-D
2h PORT-E
2l PORT-F (extra button layout)
3h PORT-G
3l
4h PORT-SEL
4l
5h SERIAL COM WRITE
5l
6h SERIAL COM READ
6l
7h
7l PORT-AD
*/
static const UINT8 port_ad[] =
{
0xcc,0xb2,0x99,0x7f,0x66,0x4c,0x33,0x19
};
READ32_HANDLER ( stv_io_r32 )
{
saturn_state *state = space->machine().driver_data<saturn_state>();
// if(LOG_IOGA) logerror("(PC=%08X): I/O r %08X & %08X\n", cpu_get_pc(&space->device()), offset*4, mem_mask);
// popmessage("SEL: %02x MUX: %02x OFF: %02x",state->m_port_sel,state->m_mux_data,offset*4);
// printf("(PC=%08X): I/O r %08X & %08X\n", cpu_get_pc(&space->device()), offset*4, mem_mask);
switch(offset)
{
case 0x00/4:
switch(state->m_port_sel)
{
case 0x77: return 0xff000000|(input_port_read(space->machine(), "P1") << 16) |0x0000ff00|(input_port_read(space->machine(), "P2"));
case 0x67:
{
switch(state->m_mux_data)
{
/*Mahjong panel interface,bit wise(ACTIVE LOW)*/
case 0xfe: return 0xff000000 | (input_port_read_safe(space->machine(), "KEY0", 0) << 16) | 0x0000ff00 | (input_port_read_safe(space->machine(), "KEY5", 0));
case 0xfd: return 0xff000000 | (input_port_read_safe(space->machine(), "KEY1", 0) << 16) | 0x0000ff00 | (input_port_read_safe(space->machine(), "KEY6", 0));
case 0xfb: return 0xff000000 | (input_port_read_safe(space->machine(), "KEY2", 0) << 16) | 0x0000ff00 | (input_port_read_safe(space->machine(), "KEY7", 0));
case 0xf7: return 0xff000000 | (input_port_read_safe(space->machine(), "KEY3", 0) << 16) | 0x0000ff00 | (input_port_read_safe(space->machine(), "KEY8", 0));
case 0xef: return 0xff000000 | (input_port_read_safe(space->machine(), "KEY4", 0) << 16) | 0x0000ff00 | (input_port_read_safe(space->machine(), "KEY9", 0));
/*Joystick panel*/
default:
//popmessage("%02x MUX DATA",state->m_mux_data);
return (input_port_read(space->machine(), "P1") << 16) | (input_port_read(space->machine(), "P2"));
}
}
case 0x47:
{
if ( strcmp(space->machine().system().name,"critcrsh") == 0 )
{
int data1 = 0, data2 = 0;
/* Critter Crusher */
data1 = input_port_read(space->machine(), "LIGHTX");
data1 = BITSWAP8(data1, 2, 3, 0, 1, 6, 7, 5, 4) & 0xf3;
data1 |= (input_port_read(space->machine(), "P1") & 1) ? 0x0 : 0x4;
data2 = input_port_read(space->machine(), "LIGHTY");
data2 = BITSWAP8(data2, 2, 3, 0, 1, 6, 7, 5, 4) & 0xf3;
data2 |= (input_port_read(space->machine(), "P1") & 1) ? 0x0 : 0x4;
return 0xff000000 | data1 << 16 | 0x0000ff00 | data2;
}
}
//default:
//case 0x40: return space->machine().rand();
default:
//popmessage("%02x PORT SEL",state->m_port_sel);
return (input_port_read(space->machine(), "P1") << 16) | (input_port_read(space->machine(), "P2"));
}
case 0x04/4:
if ( strcmp(space->machine().system().name,"critcrsh") == 0 )
return ((input_port_read(space->machine(), "SYSTEM") << 16) & ((input_port_read(space->machine(), "P1") & 1) ? 0xffef0000 : 0xffff0000)) | (state->m_ioga[1]);
else
return (input_port_read(space->machine(), "SYSTEM") << 16) | (state->m_ioga[1]);
case 0x08/4:
switch(state->m_port_sel)
{
case 0x77: return (input_port_read(space->machine(), "UNUSED") << 16) | (input_port_read(space->machine(), "EXTRA"));
case 0x67: return 0xffffffff;/**/
case 0x20: return 0xffff0000 | (state->m_ioga[2] & 0xffff);
case 0x10: return ((state->m_ioga[2] & 0xffff) << 16) | 0xffff;
case 0x60: return 0xffffffff;/**/
default:
return 0xffffffff;
}
case 0x0c/4:
switch(state->m_port_sel)
{
case 0x60: return ((state->m_ioga[2] & 0xffff) << 16) | 0xffff;
default:
//popmessage("offs: 3 %02x",state->m_port_sel);
return 0xffffffff;
}
//case 0x10/4:
case 0x14/4:
switch(state->m_port_sel)
{
case 0x77:
{
//popmessage("(PC=%06x) offs 5 %04x %02x",cpu_get_pc(&space->device()),state->m_port_sel,((state->m_ioga[5] & 0xff0000) >> 16));
logerror("(PC=%06x) offs 5 %04x %02x\n",cpu_get_pc(&space->device()),state->m_port_sel,((state->m_ioga[5] & 0xff0000) >> 16));
//stv_m_workram_h[0x8e830/4] = ((state->m_ioga[5] & 0xff0000) >> 16) ^ 0x3;
//stv_m_workram_h[0x8e834/4] = ((state->m_ioga[5] & 0xff0000) >> 16) ^ 0x3;
return (state->m_ioga[5] & 0xff0000) >> 16;//stv_m_workram_h[0x8e830/4];//sound board data
}
default: return 0xffffffff;
}
case 0x18/4:
switch(state->m_port_sel)
{
case 0x60: return state->m_ioga[5];
case 0x77:
{
//popmessage("(PC=%06x) offs 6 %04x %02x",cpu_get_pc(&space->device()),state->m_port_sel,((state->m_ioga[5] & 0xff0000) >> 16));
logerror("(PC=%06x) offs 6 %04x %02x\n",cpu_get_pc(&space->device()),state->m_port_sel,((state->m_ioga[5] & 0xff0000) >> 16));
return 0;//sound board status,non-zero = processing
}
default:
//popmessage("offs: 6 %02x",state->m_port_sel);
return 0xffffffff;
}
case 0x1c/4:
if(LOG_IOGA) logerror("(PC %s=%06x) Warning: READ from PORT_AD\n", space->device().tag(), cpu_get_pc(&space->device()));
popmessage("Read from PORT_AD");
state->m_port_i++;
return port_ad[state->m_port_i & 7];
default:
return state->m_ioga[offset];
}
}
WRITE32_HANDLER ( stv_io_w32 )
{
saturn_state *state = space->machine().driver_data<saturn_state>();
// if(LOG_IOGA) logerror("(PC=%08X): I/O w %08X = %08X & %08X\n", cpu_get_pc(&space->device()), offset*4, data, mem_mask);
// if(data != 0x0c)
// printf("(PC=%08X): I/O w %08X = %08X & %08X\n", cpu_get_pc(&space->device()), offset*4, data, mem_mask);
switch(offset)
{
case 0x04/4:
if(ACCESSING_BITS_0_7)
{
/*Why does the BIOS tests these as ACTIVE HIGH? A program bug?*/
state->m_ioga[1] = (data) & 0xff;
coin_counter_w(space->machine(), 0,~data & 0x01);
coin_counter_w(space->machine(), 1,~data & 0x02);
coin_lockout_w(space->machine(), 0,~data & 0x04);
coin_lockout_w(space->machine(), 1,~data & 0x08);
/*
other bits reserved
*/
}
break;
case 0x08/4:
if(ACCESSING_BITS_16_23)
{
state->m_ioga[2] = data >> 16;
state->m_mux_data = state->m_ioga[2];
}
else if(ACCESSING_BITS_0_7)
state->m_ioga[2] = data;
break;
case 0x0c/4:
if(ACCESSING_BITS_16_23)
state->m_ioga[3] = data;
break;
case 0x10/4:
if(ACCESSING_BITS_16_23)
state->m_port_sel = (data & 0xffff0000) >> 16;
break;
case 0x14/4:
if(ACCESSING_BITS_16_23)
state->m_ioga[5] = data;
break;
//case 0x18/4:
case 0x1c/4:
//technical bowling tests here
if(ACCESSING_BITS_16_23)
state->m_ioga[7] = data;
break;
}
}
/*
EEPROM write 0000 to address 2d
EEPROM write 0000 to address 2e

View File

@ -111,6 +111,8 @@ public:
UINT8 m_prev_bankswitch;
emu_timer *m_stv_rtc_timer;
UINT32 *m_ioga;
UINT8 m_port_sel,m_mux_data;
int m_port_i;
legacy_cpu_device* m_maincpu;
legacy_cpu_device* m_slave;
@ -220,3 +222,7 @@ WRITE32_HANDLER ( saturn_vdp2_regs_w );
VIDEO_START ( stv_vdp2 );
SCREEN_UPDATE( stv_vdp2 );
READ32_HANDLER ( stv_io_r32 );
WRITE32_HANDLER ( stv_io_w32 );

View File

@ -174,6 +174,13 @@ static int vblank_line(running_machine &machine)
}
#endif
/********************************************
*
* Bankswitch code for ST-V Multi Cart mode
*
*******************************************/
static TIMER_CALLBACK( stv_bankswitch_state )
{
saturn_state *state = machine.driver_data<saturn_state>();
@ -198,6 +205,12 @@ static void stv_select_game(running_machine &machine, int gameno)
machine.scheduler().timer_set(attotime::zero, FUNC(stv_bankswitch_state), gameno);
}
/********************************************
*
* Command functions
*
*******************************************/
static void smpc_master_on(running_machine &machine)
{
saturn_state *state = machine.driver_data<saturn_state>();
@ -260,7 +273,7 @@ static TIMER_CALLBACK( smpc_change_clock )
if(state->m_NMI_reset)
device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, PULSE_LINE);
device_set_input_line(state->m_slave, INPUT_LINE_RESET, ASSERT_LINE); // command also asserts slave cpu
device_set_input_line(state->m_slave, INPUT_LINE_RESET, ASSERT_LINE);
/* put issued command in OREG31 */
state->m_smpc.OREG[31] = 0x0e + param;
@ -607,6 +620,106 @@ static void smpc_nmi_set(running_machine &machine,UINT8 cmd)
state->m_smpc.OREG[0] = (0x80) | ((state->m_NMI_reset & 1) << 6);
}
/********************************************
*
* COMREG sub-routine
*
*******************************************/
static void smpc_comreg_exec(address_space *space, UINT8 data, UINT8 is_stv)
{
saturn_state *state = space->machine().driver_data<saturn_state>();
switch (data)
{
case 0x00:
if(LOG_SMPC) printf ("SMPC: Master ON\n");
smpc_master_on(space->machine());
break;
//case 0x01: Master OFF?
case 0x02:
case 0x03:
if(LOG_SMPC) printf ("SMPC: Slave %s\n",(data & 1) ? "off" : "on");
space->machine().scheduler().timer_set(attotime::from_usec(100), FUNC(smpc_slave_enable),data & 1);
break;
case 0x06:
case 0x07:
if(LOG_SMPC) printf ("SMPC: Sound %s\n",(data & 1) ? "off" : "on");
if(!is_stv)
space->machine().scheduler().timer_set(attotime::from_usec(100), FUNC(smpc_sound_enable),data & 1);
break;
/*CD (SH-1) ON/OFF */
//case 0x08:
//case 0x09:
case 0x0d:
if(LOG_SMPC) printf ("SMPC: System Reset\n");
smpc_system_reset(space->machine());
break;
case 0x0e:
case 0x0f:
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 ... */
space->machine().scheduler().timer_set(attotime::from_usec(6666), FUNC(smpc_change_clock),data & 1);
break;
/*"Interrupt Back"*/
case 0x10:
if(LOG_SMPC)
{
saturn_state *state = space->machine().driver_data<saturn_state>();
printf ("SMPC: Status Acquire %02x %02x %02x %d\n",state->m_smpc.IREG[0],state->m_smpc.IREG[1],state->m_smpc.IREG[2],space->machine().primary_screen->vpos());
}
if(is_stv)
space->machine().scheduler().timer_set(attotime::from_usec(700), FUNC(stv_smpc_intback),0); //TODO: variable time
else
{
int timing;
timing = 100;
if(state->m_smpc.IREG[0] != 0) // non-peripheral data
timing += 100;
if(state->m_smpc.IREG[1] & 8) // peripheral data
timing += 700;
/* TODO: check if IREG[2] is setted to 0xf0 */
if(LOG_PAD_CMD) printf("INTBACK %02x %02x %d %d\n",state->m_smpc.IREG[0],state->m_smpc.IREG[1],space->machine().primary_screen->vpos(),(int)space->machine().primary_screen->frame_number());
space->machine().scheduler().timer_set(attotime::from_usec(timing), FUNC(saturn_smpc_intback),0); //TODO: is variable time correct?
}
break;
/* RTC write*/
case 0x16:
if(LOG_SMPC) printf("SMPC: RTC write\n");
smpc_rtc_write(space->machine());
break;
/* SMPC memory setting*/
case 0x17:
if(LOG_SMPC) printf ("SMPC: memory setting\n");
smpc_memory_setting(space->machine());
break;
case 0x18:
if(LOG_SMPC) printf ("SMPC: NMI request\n");
smpc_nmi_req(space->machine());
break;
case 0x19:
case 0x1a:
if(LOG_SMPC) printf ("SMPC: NMI %sable\n",data & 1 ? "Dis" : "En");
smpc_nmi_set(space->machine(),data & 1);
break;
default:
printf ("cpu '%s' (PC=%08X) SMPC: undocumented Command %02x\n", space->device().tag(), cpu_get_pc(&space->device()), data);
}
}
/********************************************
*
* ST-V handlers
@ -639,76 +752,6 @@ READ8_HANDLER( stv_SMPC_r )
return return_data;
}
static void stv_comreg_exec(address_space *space,UINT8 data)
{
switch (data)
{
case 0x00:
if(LOG_SMPC) printf ("SMPC: Master ON\n");
smpc_master_on(space->machine());
break;
//in theory 0x01 is for Master OFF,but obviously is not used.
case 0x02:
case 0x03:
if(LOG_SMPC) printf ("SMPC: Slave %s\n",(data & 1) ? "off" : "on");
space->machine().scheduler().timer_set(attotime::from_usec(100), FUNC(smpc_slave_enable),data & 1);
break;
case 0x06:
case 0x07:
if(LOG_SMPC) printf ("SMPC: Sound %s, ignored\n",(data & 1) ? "off" : "on");
break;
/*CD (SH-1) ON/OFF,guess that this is needed for Sports Fishing games...*/
//case 0x08:
//case 0x09:
case 0x0d:
if(LOG_SMPC) printf ("SMPC: System Reset\n");
smpc_system_reset(space->machine());
break;
case 0x0e:
case 0x0f:
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 ... */
space->machine().scheduler().timer_set(attotime::from_usec(6666), FUNC(smpc_change_clock),data & 1);
break;
/*"Interrupt Back"*/
case 0x10:
if(LOG_SMPC)
{
saturn_state *state = space->machine().driver_data<saturn_state>();
printf ("SMPC: Status Acquire %02x %02x %02x %d\n",state->m_smpc.IREG[0],state->m_smpc.IREG[1],state->m_smpc.IREG[2],space->machine().primary_screen->vpos());
}
space->machine().scheduler().timer_set(attotime::from_usec(700), FUNC(stv_smpc_intback),0); //TODO: variable time
break;
/* RTC write*/
case 0x16:
if(LOG_SMPC) printf("SMPC: RTC write\n");
smpc_rtc_write(space->machine());
break;
/* SMPC memory setting*/
case 0x17:
if(LOG_SMPC) printf ("SMPC: memory setting\n");
//smpc_memory_setting(space->machine());
break;
case 0x18:
if(LOG_SMPC) printf ("SMPC: NMI request\n");
smpc_nmi_req(space->machine());
break;
case 0x19:
case 0x1a:
if(LOG_SMPC) printf ("SMPC: NMI %sable\n",data & 1 ? "Dis" : "En");
smpc_nmi_set(space->machine(),data & 1);
break;
default:
printf ("cpu '%s' (PC=%08X) SMPC: undocumented Command %02x\n", space->device().tag(), cpu_get_pc(&space->device()), data);
}
}
WRITE8_HANDLER( stv_SMPC_w )
{
saturn_state *state = space->machine().driver_data<saturn_state>();
@ -723,7 +766,7 @@ WRITE8_HANDLER( stv_SMPC_w )
if (offset == 0x1f) // COMREG
{
stv_comreg_exec(space,data);
smpc_comreg_exec(space,data,1);
// we've processed the command, clear status flag
if(data != 0x10 && data != 0x02 && data != 0x03 && data != 0xe && data != 0xf)
@ -846,81 +889,6 @@ READ8_HANDLER( saturn_SMPC_r )
return return_data;
}
static void saturn_comreg_exec(address_space *space,UINT8 data)
{
saturn_state *state = space->machine().driver_data<saturn_state>();
switch (data)
{
case 0x00:
if(LOG_SMPC) printf ("SMPC: Master ON\n");
smpc_master_on(space->machine());
break;
//in theory 0x01 is for Master OFF
case 0x02:
case 0x03:
if(LOG_SMPC) printf ("SMPC: Slave %s\n",(data & 1) ? "off" : "on");
space->machine().scheduler().timer_set(attotime::from_usec(100), FUNC(smpc_slave_enable),data & 1);
break;
case 0x06:
case 0x07:
if(LOG_SMPC) printf ("SMPC: Sound %s\n",(data & 1) ? "off" : "on");
space->machine().scheduler().timer_set(attotime::from_usec(100), FUNC(smpc_sound_enable),data & 1);
break;
/*CD (SH-1) ON/OFF,guess that this is needed for Sports Fishing games...*/
//case 0x08:
//case 0x09:
case 0x0d:
if(LOG_SMPC) printf ("SMPC: System Reset\n");
smpc_system_reset(space->machine());
break;
case 0x0e:
case 0x0f:
if(LOG_SMPC) printf ("SMPC: Change Clock to %s\n",data & 1 ? "320" : "352");
space->machine().scheduler().timer_set(attotime::from_usec(6666), FUNC(smpc_change_clock),data & 1);
break;
/*"Interrupt Back"*/
case 0x10:
if(LOG_SMPC) printf ("SMPC: Status Acquire (IntBack)\n");
int timing;
timing = 100;
if(state->m_smpc.IREG[0] != 0) // non-peripheral data
timing += 100;
if(state->m_smpc.IREG[1] & 8) // peripheral data
timing += 700;
/* TODO: check if IREG[2] is setted to 0xf0 */
if(LOG_PAD_CMD) printf("INTBACK %02x %02x %d %d\n",state->m_smpc.IREG[0],state->m_smpc.IREG[1],space->machine().primary_screen->vpos(),(int)space->machine().primary_screen->frame_number());
space->machine().scheduler().timer_set(attotime::from_usec(timing), FUNC(saturn_smpc_intback),0); //TODO: is variable time correct?
break;
/* RTC write*/
case 0x16:
if(LOG_SMPC) printf("SMPC: RTC write\n");
smpc_rtc_write(space->machine());
break;
/* SMPC memory setting*/
case 0x17:
if(LOG_SMPC) printf ("SMPC: memory setting\n");
smpc_memory_setting(space->machine());
break;
case 0x18:
if(LOG_SMPC) printf ("SMPC: NMI request\n");
smpc_nmi_req(space->machine());
break;
case 0x19:
case 0x1a:
if(LOG_SMPC) printf ("SMPC: NMI %sable\n",data & 1 ? "Dis" : "En");
smpc_nmi_set(space->machine(),data & 1);
break;
default:
printf ("cpu %s (PC=%08X) SMPC: undocumented Command %02x\n", space->device().tag(), cpu_get_pc(&space->device()), data);
}
}
WRITE8_HANDLER( saturn_SMPC_w )
{
saturn_state *state = space->machine().driver_data<saturn_state>();
@ -955,7 +923,7 @@ WRITE8_HANDLER( saturn_SMPC_w )
if (offset == 0x1f)
{
saturn_comreg_exec(space,data);
smpc_comreg_exec(space,data,0);
// we've processed the command, clear status flag
if(data != 0x10 && data != 2 && data != 3 && data != 6 && data != 7 && data != 0x0e && data != 0x0f)