From 13c095c03cc0766bbb4eef2aa2947b5e0389ce2e Mon Sep 17 00:00:00 2001 From: Angelo Salese Date: Tue, 6 Apr 2010 23:04:22 +0000 Subject: [PATCH] First step in supporting master cycle delays in the SNES driver [Angelo Salese] --- src/emu/cpu/g65816/g65816.c | 31 ++++++++++++++++++++++++++++++- src/emu/cpu/g65816/g65816.h | 6 ++++++ src/emu/cpu/g65816/g65816cm.h | 3 ++- src/mame/drivers/nss.c | 2 +- src/mame/drivers/snesb.c | 2 +- 5 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/emu/cpu/g65816/g65816.c b/src/emu/cpu/g65816/g65816.c index 3d1529daf0a..953dd27c0b1 100644 --- a/src/emu/cpu/g65816/g65816.c +++ b/src/emu/cpu/g65816/g65816.c @@ -100,7 +100,7 @@ INLINE g65816i_cpu_struct *get_safe_token(running_device *device) assert(device != NULL); assert(device->token != NULL); assert(device->type == CPU); - assert(cpu_get_type(device) == CPU_G65816); + assert(cpu_get_type(device) == CPU_G65816 || cpu_get_type(device) == CPU_5A22); return (g65816i_cpu_struct *)device->token; } @@ -339,6 +339,7 @@ static CPU_INIT( g65816 ) g65816_set_irq_callback(cpustate, irqcallback); cpustate->device = device; cpustate->program = device->space(AS_PROGRAM); + cpustate->cpu_type = CPU_TYPE_G65816; state_save_register_device_item(device, 0, cpustate->a); state_save_register_device_item(device, 0, cpustate->b); @@ -523,6 +524,34 @@ CPU_GET_INFO( g65816 ) } } +/* +SNES specific, used to handle master cycles +*/ + +static CPU_INIT( 5a22 ) +{ + g65816i_cpu_struct *cpustate = get_safe_token(device); + + CPU_INIT_CALL(g65816); + + cpustate->cpu_type = CPU_TYPE_5A22; +} + + +CPU_GET_INFO( 5a22 ) +{ + switch (state) + { + /* --- the following bits of info are returned as pointers to data or functions --- */ + case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(5a22); break; + + /* --- the following bits of info are returned as NULL-terminated strings --- */ + case DEVINFO_STR_NAME: strcpy(info->s, "5A22"); break; + + default: CPU_GET_INFO_CALL(g65816); break; + } +} + /* ======================================================================== */ /* ============================== END OF FILE ============================= */ /* ======================================================================== */ diff --git a/src/emu/cpu/g65816/g65816.h b/src/emu/cpu/g65816/g65816.h index f1fd60acccd..11e09c9ebcd 100644 --- a/src/emu/cpu/g65816/g65816.h +++ b/src/emu/cpu/g65816/g65816.h @@ -59,6 +59,12 @@ enum /* Main interface function */ CPU_GET_INFO( g65816 ); #define CPU_G65816 CPU_GET_INFO_NAME( g65816 ) +CPU_GET_INFO( 5a22 ); +#define CPU_5A22 CPU_GET_INFO_NAME( 5a22 ) + +#define CPU_TYPE_G65816 0 +#define CPU_TYPE_5A22 1 + void g65816_set_read_vector_callback(running_device *device, read8_space_func read_vector); diff --git a/src/emu/cpu/g65816/g65816cm.h b/src/emu/cpu/g65816/g65816cm.h index ef6cd9e12f9..b1743d4ebda 100644 --- a/src/emu/cpu/g65816/g65816cm.h +++ b/src/emu/cpu/g65816/g65816cm.h @@ -106,6 +106,7 @@ struct _g65816i_cpu_struct uint source; uint destination; int ICount; + int cpu_type; }; extern void (*const *const g65816i_opcodes[])(g65816i_cpu_struct *cpustate); @@ -242,7 +243,7 @@ INLINE void g65816i_set_execution_mode(g65816i_cpu_struct *cpustate, uint mode) #define CLK_W_S 2 #define CLK_W_SIY 5 -#define CLK(A) CLOCKS -= (A) +#define CLK(A) CLOCKS -= (cpustate->cpu_type == CPU_TYPE_G65816 ? A : A*6) #define USE_ALL_CLKS() CLOCKS = 0 diff --git a/src/mame/drivers/nss.c b/src/mame/drivers/nss.c index f6162b459eb..8730a5328ba 100644 --- a/src/mame/drivers/nss.c +++ b/src/mame/drivers/nss.c @@ -449,7 +449,7 @@ static MACHINE_DRIVER_START( snes ) MDRV_DRIVER_DATA(snes_state) /* basic machine hardware */ - MDRV_CPU_ADD("maincpu", G65816, 3580000) /* 2.68Mhz, also 3.58Mhz */ + MDRV_CPU_ADD("maincpu", 5A22, 3580000*6) /* 2.68Mhz, also 3.58Mhz */ MDRV_CPU_PROGRAM_MAP(snes_map) MDRV_CPU_ADD("soundcpu", SPC700, 2048000/2) /* 2.048 Mhz, but internal divider */ diff --git a/src/mame/drivers/snesb.c b/src/mame/drivers/snesb.c index 74f1445048e..3ab58c3152f 100644 --- a/src/mame/drivers/snesb.c +++ b/src/mame/drivers/snesb.c @@ -503,7 +503,7 @@ static MACHINE_DRIVER_START( kinstb ) MDRV_DRIVER_DATA(snes_state) /* basic machine hardware */ - MDRV_CPU_ADD("maincpu", G65816, 3580000) /* 2.68Mhz, also 3.58Mhz */ + MDRV_CPU_ADD("maincpu", 5A22, 3580000*6) /* 2.68Mhz, also 3.58Mhz */ MDRV_CPU_PROGRAM_MAP(snesb_map) /* audio CPU */