From 98c40f06dbdd764d8c1ee1409f1103ec6ec68f45 Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Tue, 16 Dec 2008 15:02:15 +0000 Subject: [PATCH] Made CPUs into proper devices. CPUs are now added in the machine configuration just as any other device, and the standard CPU configuration is performed via the inline configuration macros. Change cpu_type from an enumeration into a pointer to the CPU's get_info function, very similar to device behavior. For now all CPUs are declared in cpuintrf.h, but eventually they should be declared in the CPU's header file, and the driver should #include that header. Added function cpu_get_type() to return the CPU type. Changed several cpu_* functions into macros that call through to the equivalent device_* function. The device system now maintains a parallel list of devices based on type, for faster iteration through all devices of a given type. Cleaned up code that looped over CPUs via the machine->cpu array to now loop using the type-based device list. Removed start/stop/reset/nvram functions from the device_config in favor of grabbing them as needed. Cleaned up the generic interrupt_enable code to work with CPU devices instead of numbers. Mapped the devtag_* functions to device_* functions via macros instead of parallel implementations. --- src/emu/cpu/cubeqcpu/cubeqcpu.c | 2 +- src/emu/cpu/pic16c5x/16c5xdsm.c | 2 +- src/emu/cpu/pic16c5x/pic16c5x.c | 94 +-- src/emu/cpu/pic16c5x/pic16c5x.h | 2 +- src/emu/cpu/se3208/se3208.c | 36 +- src/emu/cpu/se3208/se3208.h | 4 +- src/emu/cpu/se3208/se3208dis.c | 2 +- src/emu/cpu/sh2/sh2comn.c | 10 +- src/emu/cpu/tms34010/tms34010.c | 43 +- src/emu/cpu/z80/z80daisy.c | 3 +- src/emu/cpuexec.c | 764 +++++++++++----------- src/emu/cpuexec.h | 110 +++- src/emu/cpuintrf.c | 1083 +------------------------------ src/emu/cpuintrf.h | 777 ++++++++++++++-------- src/emu/debug/debugcmd.c | 292 ++++----- src/emu/debug/debugcpu.c | 339 +++++----- src/emu/debug/debughlp.c | 76 +-- src/emu/debug/debugvw.c | 130 ++-- src/emu/deprecat.h | 5 +- src/emu/devintrf.c | 335 +++------- src/emu/devintrf.h | 92 +-- src/emu/info.c | 20 +- src/emu/machine/8237dma.c | 4 +- src/emu/machine/8237dma.h | 2 +- src/emu/machine/8257dma.c | 4 +- src/emu/machine/8257dma.h | 2 +- src/emu/machine/generic.c | 46 +- src/emu/machine/generic.h | 2 +- src/emu/machine/z80dma.c | 4 +- src/emu/machine/z80dma.h | 2 +- src/emu/mame.c | 73 +-- src/emu/mconfig.c | 159 +---- src/emu/mconfig.h | 67 -- src/emu/memory.c | 212 +++--- src/emu/memory.h | 2 +- src/emu/romload.c | 5 +- src/emu/sndintrf.c | 6 +- src/emu/sound/nes_apu.c | 1 + src/emu/ui.c | 20 +- src/emu/validity.c | 119 ++-- src/emu/video.c | 5 +- src/mame/audio/mario.c | 2 +- src/mame/audio/namcoc7x.c | 8 +- src/mame/drivers/20pacgal.c | 2 +- src/mame/drivers/atarig1.c | 2 +- src/mame/drivers/atarisy1.c | 12 +- src/mame/drivers/brkthru.c | 6 +- src/mame/drivers/cclimber.c | 2 +- src/mame/drivers/champbas.c | 2 +- src/mame/drivers/cojag.c | 2 +- src/mame/drivers/crbaloon.c | 2 +- src/mame/drivers/cyberbal.c | 4 +- src/mame/drivers/deniam.c | 2 +- src/mame/drivers/dkong.c | 6 +- src/mame/drivers/espial.c | 2 +- src/mame/drivers/filetto.c | 2 +- src/mame/drivers/galaga.c | 6 +- src/mame/drivers/gamecstl.c | 4 +- src/mame/drivers/gaplus.c | 8 +- src/mame/drivers/gauntlet.c | 2 +- src/mame/drivers/genesis.c | 2 +- src/mame/drivers/harddriv.c | 4 +- src/mame/drivers/itech8.c | 8 +- src/mame/drivers/kyugo.c | 2 +- src/mame/drivers/mappy.c | 14 +- src/mame/drivers/mario.c | 2 +- src/mame/drivers/mediagx.c | 4 +- src/mame/drivers/nbmj8991.c | 2 +- src/mame/drivers/pacland.c | 4 +- src/mame/drivers/polepos.c | 4 +- src/mame/drivers/rallyx.c | 4 +- src/mame/drivers/rampart.c | 2 +- src/mame/drivers/retofinv.c | 4 +- src/mame/drivers/segas18.c | 2 +- src/mame/drivers/seibuspi.c | 2 +- src/mame/drivers/seicross.c | 2 +- src/mame/drivers/skykid.c | 4 +- src/mame/drivers/taitowlf.c | 4 +- src/mame/drivers/toypop.c | 14 +- src/mame/drivers/warpwarp.c | 2 +- src/mame/drivers/xybots.c | 2 +- src/mame/machine/atarigen.c | 8 +- src/mame/machine/atarigen.h | 2 +- src/mame/machine/bublbobl.c | 2 +- src/mame/machine/leland.c | 2 +- src/mame/machine/mexico86.c | 2 +- src/mame/machine/namcos1.c | 10 +- src/mame/machine/segaic16.c | 2 +- src/mame/machine/slapstic.c | 5 +- src/mame/machine/taitosj.c | 4 +- src/mame/machine/tnzs.c | 2 +- src/mame/machine/toaplan1.c | 2 +- src/mame/video/taitoic.c | 41 +- 93 files changed, 1997 insertions(+), 3205 deletions(-) diff --git a/src/emu/cpu/cubeqcpu/cubeqcpu.c b/src/emu/cpu/cubeqcpu/cubeqcpu.c index 19e08c491f5..6d024358ab0 100644 --- a/src/emu/cpu/cubeqcpu/cubeqcpu.c +++ b/src/emu/cpu/cubeqcpu/cubeqcpu.c @@ -12,7 +12,7 @@ #include "debugger.h" #include "cubeqcpu.h" -#include "cpuexec.h" +#include "driver.h" /*************************************************************************** diff --git a/src/emu/cpu/pic16c5x/16c5xdsm.c b/src/emu/cpu/pic16c5x/16c5xdsm.c index 8a112002914..66fccc9e327 100644 --- a/src/emu/cpu/pic16c5x/16c5xdsm.c +++ b/src/emu/cpu/pic16c5x/16c5xdsm.c @@ -151,7 +151,7 @@ static void InitDasm16C5x(void) OpInizialized = 1; } -CPU_DISASSEMBLE( pic16C5x ) +CPU_DISASSEMBLE( pic16c5x ) { int a, b, d, f, k; /* these can all be filled in by parsing an instruction */ int i; diff --git a/src/emu/cpu/pic16c5x/pic16c5x.c b/src/emu/cpu/pic16c5x/pic16c5x.c index d150a8a1f8b..b6cdb335936 100644 --- a/src/emu/cpu/pic16c5x/pic16c5x.c +++ b/src/emu/cpu/pic16c5x/pic16c5x.c @@ -682,7 +682,7 @@ static const pic16c5x_opcode_00x opcode_00x[16]= * Inits CPU emulation ****************************************************************************/ -static CPU_INIT( pic16C5x ) +static CPU_INIT( pic16c5x ) { pic16c5x_state *cpustate = device->token; @@ -730,7 +730,7 @@ static CPU_INIT( pic16C5x ) * Reset registers to their initial values ****************************************************************************/ -static void pic16C5x_reset_regs(pic16c5x_state *cpustate) +static void pic16c5x_reset_regs(pic16c5x_state *cpustate) { cpustate->PC = cpustate->reset_vector; cpustate->CONFIG = cpustate->temp_config; @@ -747,10 +747,10 @@ static void pic16C5x_reset_regs(pic16c5x_state *cpustate) cpustate->inst_cycles = 0; } -static void pic16C5x_soft_reset(pic16c5x_state *cpustate) +static void pic16c5x_soft_reset(pic16c5x_state *cpustate) { cpustate->STATUS &= 0x1f; - pic16C5x_reset_regs(cpustate); + pic16c5x_reset_regs(cpustate); } void pic16c5x_set_config(const device_config *cpu, int data) @@ -766,7 +766,7 @@ void pic16c5x_set_config(const device_config *cpu, int data) * Shut down CPU emulation ****************************************************************************/ -static CPU_EXIT( pic16C5x ) +static CPU_EXIT( pic16c5x ) { /* nothing to do */ } @@ -776,7 +776,7 @@ static CPU_EXIT( pic16C5x ) * WatchDog ****************************************************************************/ -static void pic16C5x_update_watchdog(pic16c5x_state *cpustate, int counts) +static void pic16c5x_update_watchdog(pic16c5x_state *cpustate, int counts) { /* WatchDog is set up to count 18,000 (0x464f hex) ticks to provide */ /* the timeout period of 0.018ms based on a 4MHz input clock. */ @@ -802,12 +802,12 @@ static void pic16C5x_update_watchdog(pic16c5x_state *cpustate, int counts) if (cpustate->prescaler >= (1 << PS)) { /* Prescale values from 1 to 128 */ cpustate->prescaler = 0; CLR(cpustate, TO_FLAG); - pic16C5x_soft_reset(cpustate); + pic16c5x_soft_reset(cpustate); } } else { CLR(cpustate, TO_FLAG); - pic16C5x_soft_reset(cpustate); + pic16c5x_soft_reset(cpustate); } } } @@ -818,7 +818,7 @@ static void pic16C5x_update_watchdog(pic16c5x_state *cpustate, int counts) * Update Timer ****************************************************************************/ -static void pic16C5x_update_timer(pic16c5x_state *cpustate, int counts) +static void pic16c5x_update_timer(pic16c5x_state *cpustate, int counts) { if (PSA == 0) { cpustate->prescaler += counts; @@ -837,7 +837,7 @@ static void pic16C5x_update_timer(pic16c5x_state *cpustate, int counts) * Execute IPeriod. Return 0 if emulation should be stopped ****************************************************************************/ -static CPU_EXECUTE( pic16C5x ) +static CPU_EXECUTE( pic16c5x ) { pic16c5x_state *cpustate = device->token; int T0_in; @@ -850,7 +850,7 @@ static CPU_EXECUTE( pic16C5x ) cpustate->inst_cycles = 1; debugger_instruction_hook(device, cpustate->PC); if (WDTE) { - pic16C5x_update_watchdog(cpustate, 1); + pic16c5x_update_watchdog(cpustate, 1); } } else @@ -876,12 +876,12 @@ static CPU_EXECUTE( pic16C5x ) T0_in = S_T0_IN; if (T0SE) { /* Count rising edge */ if (POSITIVE_EDGE_T0) { - pic16C5x_update_timer(cpustate, 1); + pic16c5x_update_timer(cpustate, 1); } } else { /* Count falling edge */ if (NEGATIVE_EDGE_T0) { - pic16C5x_update_timer(cpustate, 1); + pic16c5x_update_timer(cpustate, 1); } } cpustate->old_T0 = T0_in; @@ -891,11 +891,11 @@ static CPU_EXECUTE( pic16C5x ) cpustate->delay_timer--; } else { - pic16C5x_update_timer(cpustate, cpustate->inst_cycles); + pic16c5x_update_timer(cpustate, cpustate->inst_cycles); } } if (WDTE) { - pic16C5x_update_watchdog(cpustate, cpustate->inst_cycles); + pic16c5x_update_watchdog(cpustate, cpustate->inst_cycles); } } @@ -912,7 +912,7 @@ static CPU_EXECUTE( pic16C5x ) * Generic set_info **************************************************************************/ -static CPU_SET_INFO( pic16C5x ) +static CPU_SET_INFO( pic16c5x ) { pic16c5x_state *cpustate = device->token; @@ -946,7 +946,7 @@ static CPU_SET_INFO( pic16C5x ) * Generic get_info **************************************************************************/ -static CPU_GET_INFO( pic16C5x ) +static CPU_GET_INFO( pic16c5x ) { pic16c5x_state *cpustate = (device != NULL) ? device->token : NULL; @@ -995,13 +995,13 @@ static CPU_GET_INFO( pic16C5x ) case CPUINFO_INT_REGISTER + PIC16C5x_FSR: info->i = (cpustate->FSR & cpustate->picRAMmask); break; /* --- the following bits of info are returned as pointers to data or functions --- */ - case CPUINFO_PTR_SET_INFO: info->setinfo = CPU_SET_INFO_NAME(pic16C5x); break; - case CPUINFO_PTR_INIT: info->init = CPU_INIT_NAME(pic16C5x); break; + case CPUINFO_PTR_SET_INFO: info->setinfo = CPU_SET_INFO_NAME(pic16c5x); break; + case CPUINFO_PTR_INIT: info->init = CPU_INIT_NAME(pic16c5x); break; case CPUINFO_PTR_RESET: /* set per-CPU */ break; - case CPUINFO_PTR_EXIT: info->exit = CPU_EXIT_NAME(pic16C5x); break; - case CPUINFO_PTR_EXECUTE: info->execute = CPU_EXECUTE_NAME(pic16C5x); break; + case CPUINFO_PTR_EXIT: info->exit = CPU_EXIT_NAME(pic16c5x); break; + case CPUINFO_PTR_EXECUTE: info->execute = CPU_EXECUTE_NAME(pic16c5x); break; case CPUINFO_PTR_BURN: info->burn = NULL; break; - case CPUINFO_PTR_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(pic16C5x); break; + case CPUINFO_PTR_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(pic16c5x); break; case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &cpustate->icount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ @@ -1066,14 +1066,14 @@ ADDRESS_MAP_END * PIC16C54 Reset ****************************************************************************/ -static CPU_RESET( pic16C54 ) +static CPU_RESET( pic16c54 ) { pic16c5x_state *cpustate = device->token; cpustate->picmodel = 0x16C54; cpustate->picRAMmask = 0x1f; cpustate->reset_vector = 0x1ff; - pic16C5x_reset_regs(cpustate); + pic16c5x_reset_regs(cpustate); cpustate->STATUS = 0x00; SET(cpustate, TO_FLAG); SET(cpustate, PD_FLAG); @@ -1084,19 +1084,19 @@ static CPU_RESET( pic16C54 ) * CPU-specific get_info **************************************************************************/ -CPU_GET_INFO( pic16C54 ) +CPU_GET_INFO( pic16c54 ) { switch (state) { /* --- the following bits of info are returned as pointers to data or functions --- */ - case CPUINFO_PTR_RESET: info->reset = CPU_RESET_NAME(pic16C54); break; + case CPUINFO_PTR_RESET: info->reset = CPU_RESET_NAME(pic16c54); break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map16 = ADDRESS_MAP_NAME(pic16c54_rom); break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA: info->internal_map8 = ADDRESS_MAP_NAME(pic16c54_ram); break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, "PIC16C54"); break; - default: CPU_GET_INFO_CALL(pic16C5x); break; + default: CPU_GET_INFO_CALL(pic16c5x); break; } } #endif @@ -1120,14 +1120,14 @@ ADDRESS_MAP_END * PIC16C55 Reset ****************************************************************************/ -static CPU_RESET( pic16C55 ) +static CPU_RESET( pic16c55 ) { pic16c5x_state *cpustate = device->token; cpustate->picmodel = 0x16C55; cpustate->picRAMmask = 0x1f; cpustate->reset_vector = 0x1ff; - pic16C5x_reset_regs(cpustate); + pic16c5x_reset_regs(cpustate); cpustate->STATUS = 0x00; SET(cpustate, TO_FLAG); SET(cpustate, PD_FLAG); @@ -1138,19 +1138,19 @@ static CPU_RESET( pic16C55 ) * CPU-specific get_info **************************************************************************/ -CPU_GET_INFO( pic16C55 ) +CPU_GET_INFO( pic16c55 ) { switch (state) { /* --- the following bits of info are returned as pointers to data or functions --- */ - case CPUINFO_PTR_RESET: info->reset = CPU_RESET_NAME(pic16C55); break; + case CPUINFO_PTR_RESET: info->reset = CPU_RESET_NAME(pic16c55); break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map16 = ADDRESS_MAP_NAME(pic16c55_rom); break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA: info->internal_map8 = ADDRESS_MAP_NAME(pic16c55_ram); break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, "PIC16C55"); break; - default: CPU_GET_INFO_CALL(pic16C5x); break; + default: CPU_GET_INFO_CALL(pic16c5x); break; } } #endif @@ -1174,14 +1174,14 @@ ADDRESS_MAP_END * PIC16C56 Reset ****************************************************************************/ -static CPU_RESET( pic16C56 ) +static CPU_RESET( pic16c56 ) { pic16c5x_state *cpustate = device->token; cpustate->picmodel = 0x16C56; cpustate->picRAMmask = 0x1f; cpustate->reset_vector = 0x3ff; - pic16C5x_reset_regs(cpustate); + pic16c5x_reset_regs(cpustate); cpustate->STATUS = 0x00; SET(cpustate, TO_FLAG); SET(cpustate, PD_FLAG); @@ -1192,12 +1192,12 @@ static CPU_RESET( pic16C56 ) * CPU-specific get_info **************************************************************************/ -CPU_GET_INFO( pic16C56 ) +CPU_GET_INFO( pic16c56 ) { switch (state) { /* --- the following bits of info are returned as pointers to data or functions --- */ - case CPUINFO_PTR_RESET: info->reset = CPU_RESET_NAME(pic16C56); break; + case CPUINFO_PTR_RESET: info->reset = CPU_RESET_NAME(pic16c56); break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map16 = ADDRESS_MAP_NAME(pic16c56_rom); break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA: info->internal_map8 = ADDRESS_MAP_NAME(pic16c56_ram); break; @@ -1206,7 +1206,7 @@ CPU_GET_INFO( pic16C56 ) /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, "PIC16C56"); break; - default: CPU_GET_INFO_CALL(pic16C5x); break; + default: CPU_GET_INFO_CALL(pic16c5x); break; } } #endif @@ -1233,14 +1233,14 @@ ADDRESS_MAP_END * PIC16C57 Reset ****************************************************************************/ -static CPU_RESET( pic16C57 ) +static CPU_RESET( pic16c57 ) { pic16c5x_state *cpustate = device->token; cpustate->picmodel = 0x16C57; cpustate->picRAMmask = 0x7f; cpustate->reset_vector = 0x7ff; - pic16C5x_reset_regs(cpustate); + pic16c5x_reset_regs(cpustate); cpustate->STATUS = 0x00; SET(cpustate, TO_FLAG); SET(cpustate, PD_FLAG); @@ -1251,12 +1251,12 @@ static CPU_RESET( pic16C57 ) * CPU-specific get_info **************************************************************************/ -CPU_GET_INFO( pic16C57 ) +CPU_GET_INFO( pic16c57 ) { switch (state) { /* --- the following bits of info are returned as pointers to data or functions --- */ - case CPUINFO_PTR_RESET: info->reset = CPU_RESET_NAME(pic16C57); break; + case CPUINFO_PTR_RESET: info->reset = CPU_RESET_NAME(pic16c57); break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map16 = ADDRESS_MAP_NAME(pic16c57_rom); break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA: info->internal_map8 = ADDRESS_MAP_NAME(pic16c57_ram); break; @@ -1266,7 +1266,7 @@ CPU_GET_INFO( pic16C57 ) /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, "PIC16C57"); break; - default: CPU_GET_INFO_CALL(pic16C5x); break; + default: CPU_GET_INFO_CALL(pic16c5x); break; } } #endif @@ -1293,14 +1293,14 @@ ADDRESS_MAP_END * PIC16C58 Reset ****************************************************************************/ -static CPU_RESET( pic16C58 ) +static CPU_RESET( pic16c58 ) { pic16c5x_state *cpustate = device->token; cpustate->picmodel = 0x16C58; cpustate->picRAMmask = 0x7f; cpustate->reset_vector = 0x7ff; - pic16C5x_reset_regs(cpustate); + pic16c5x_reset_regs(cpustate); cpustate->STATUS = 0x00; SET(cpustate, TO_FLAG); SET(cpustate, PD_FLAG); @@ -1311,12 +1311,12 @@ static CPU_RESET( pic16C58 ) * CPU-specific get_info **************************************************************************/ -CPU_GET_INFO( pic16C58 ) +CPU_GET_INFO( pic16c58 ) { switch (state) { /* --- the following bits of info are returned as pointers to data or functions --- */ - case CPUINFO_PTR_RESET: info->reset = CPU_RESET_NAME(pic16C58); break; + case CPUINFO_PTR_RESET: info->reset = CPU_RESET_NAME(pic16c58); break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map16 = ADDRESS_MAP_NAME(pic16c58_rom); break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA: info->internal_map8 = ADDRESS_MAP_NAME(pic16c58_ram); break; @@ -1326,7 +1326,7 @@ CPU_GET_INFO( pic16C58 ) /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, "PIC16C58"); break; - default: CPU_GET_INFO_CALL(pic16C5x); break; + default: CPU_GET_INFO_CALL(pic16c5x); break; } } #endif diff --git a/src/emu/cpu/pic16c5x/pic16c5x.h b/src/emu/cpu/pic16c5x/pic16c5x.h index 676b3c570ed..aad94b198ef 100644 --- a/src/emu/cpu/pic16c5x/pic16c5x.h +++ b/src/emu/cpu/pic16c5x/pic16c5x.h @@ -129,7 +129,7 @@ CPU_GET_INFO( pic16C58 ); #if (HAS_PIC16C54) || (HAS_PIC16C55) || (HAS_PIC16C56) || (HAS_PIC16C57) || (HAS_PIC16C58) -CPU_DISASSEMBLE( pic16C5x ); +CPU_DISASSEMBLE( pic16c5x ); #endif diff --git a/src/emu/cpu/se3208/se3208.c b/src/emu/cpu/se3208/se3208.c index 319c5b95420..aff128881ec 100644 --- a/src/emu/cpu/se3208/se3208.c +++ b/src/emu/cpu/se3208/se3208.c @@ -27,7 +27,7 @@ struct _se3208_state_t UINT8 IRQ; UINT8 NMI; - int SE3208_ICount; + int icount; }; #define FLAG_C 0x0080 @@ -1702,7 +1702,7 @@ static void BuildTable(void) OpTable[i]=DecodeOp(i); } -static CPU_RESET( SE3208 ) +static CPU_RESET( se3208 ) { se3208_state_t *se3208_state = device->token; @@ -1745,11 +1745,11 @@ static void SE3208_Interrupt(se3208_state_t *se3208_state) } -static CPU_EXECUTE( SE3208 ) +static CPU_EXECUTE( se3208 ) { se3208_state_t *se3208_state = device->token; - se3208_state->SE3208_ICount=cycles; + se3208_state->icount=cycles; do { UINT16 Opcode=memory_decrypted_read_word(se3208_state->program, WORD_XOR_LE(se3208_state->PC)); @@ -1769,13 +1769,13 @@ static CPU_EXECUTE( SE3208 ) { SE3208_Interrupt(se3208_state); } - --(se3208_state->SE3208_ICount); - } while(se3208_state->SE3208_ICount>0); + --(se3208_state->icount); + } while(se3208_state->icount>0); - return cycles-se3208_state->SE3208_ICount; + return cycles-se3208_state->icount; } -static CPU_INIT( SE3208 ) +static CPU_INIT( se3208 ) { se3208_state_t *se3208_state = device->token; @@ -1786,7 +1786,7 @@ static CPU_INIT( SE3208 ) se3208_state->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM); } -static CPU_EXIT( SE3208 ) +static CPU_EXIT( se3208 ) { if(OpTable) free(OpTable); @@ -1802,7 +1802,7 @@ static void set_irq_line(se3208_state_t *se3208_state, int line,int state) } -static CPU_SET_INFO( SE3208 ) +static CPU_SET_INFO( se3208 ) { se3208_state_t *se3208_state = device->token; @@ -1830,7 +1830,7 @@ static CPU_SET_INFO( SE3208 ) } -CPU_GET_INFO( SE3208 ) +CPU_GET_INFO( se3208 ) { se3208_state_t *se3208_state = (device != NULL) ? device->token : NULL; @@ -1879,14 +1879,14 @@ CPU_GET_INFO( SE3208 ) case CPUINFO_INT_REGISTER + SE3208_R7: info->i = se3208_state->R[ 7]; break; /* --- the following bits of info are returned as pointers to data or functions --- */ - case CPUINFO_PTR_SET_INFO: info->setinfo = CPU_SET_INFO_NAME(SE3208); break; - case CPUINFO_PTR_INIT: info->init = CPU_INIT_NAME(SE3208); break; - case CPUINFO_PTR_RESET: info->reset = CPU_RESET_NAME(SE3208); break; - case CPUINFO_PTR_EXIT: info->exit = CPU_EXIT_NAME(SE3208); break; - case CPUINFO_PTR_EXECUTE: info->execute = CPU_EXECUTE_NAME(SE3208);break; + case CPUINFO_PTR_SET_INFO: info->setinfo = CPU_SET_INFO_NAME(se3208); break; + case CPUINFO_PTR_INIT: info->init = CPU_INIT_NAME(se3208); break; + case CPUINFO_PTR_RESET: info->reset = CPU_RESET_NAME(se3208); break; + case CPUINFO_PTR_EXIT: info->exit = CPU_EXIT_NAME(se3208); break; + case CPUINFO_PTR_EXECUTE: info->execute = CPU_EXECUTE_NAME(se3208);break; case CPUINFO_PTR_BURN: info->burn = NULL; break; - case CPUINFO_PTR_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(SE3208); break; - case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &se3208_state->SE3208_ICount; break; + case CPUINFO_PTR_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(se3208); break; + case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &se3208_state->icount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, "SE3208"); break; diff --git a/src/emu/cpu/se3208/se3208.h b/src/emu/cpu/se3208/se3208.h index 0d23d7faa68..01c7177b992 100644 --- a/src/emu/cpu/se3208/se3208.h +++ b/src/emu/cpu/se3208/se3208.h @@ -8,6 +8,6 @@ enum #define SE3208_INT 0 -extern CPU_GET_INFO( SE3208 ); +extern CPU_GET_INFO( se3208 ); -CPU_DISASSEMBLE( SE3208 ); +CPU_DISASSEMBLE( se3208 ); diff --git a/src/emu/cpu/se3208/se3208dis.c b/src/emu/cpu/se3208/se3208dis.c index 1a7299066be..8bff0d59470 100644 --- a/src/emu/cpu/se3208/se3208dis.c +++ b/src/emu/cpu/se3208/se3208dis.c @@ -1400,7 +1400,7 @@ static _OP DecodeOp(UINT16 Opcode) } -CPU_DISASSEMBLE( SE3208 ) +CPU_DISASSEMBLE( se3208 ) { UINT16 Opcode; diff --git a/src/emu/cpu/sh2/sh2comn.c b/src/emu/cpu/sh2/sh2comn.c index 95a5a2dad95..f4813844db8 100644 --- a/src/emu/cpu/sh2/sh2comn.c +++ b/src/emu/cpu/sh2/sh2comn.c @@ -104,7 +104,7 @@ static void sh2_timer_activate(SH2 *sh2) sh2->frc_base = cpu_get_total_cycles(sh2->device); timer_adjust_oneshot(sh2->timer, cpu_clocks_to_attotime(sh2->device, max_delta), 0); } else { - logerror("SH2.%d: Timer event in %d cycles of external clock", cpu_get_index(sh2->device), max_delta); + logerror("SH2.%s: Timer event in %d cycles of external clock", sh2->device->tag, max_delta); } } } @@ -141,7 +141,7 @@ TIMER_CALLBACK( sh2_dmac_callback ) int dma = param & 1; SH2 *sh2 = ptr; - LOG(("SH2.%d: DMA %d complete\n", cpu_get_index(sh2->device), dma)); + LOG(("SH2.%s: DMA %d complete\n", sh2->device->tag, dma)); sh2->m[0x63+4*dma] |= 2; sh2->dma_timer_active[dma] = 0; sh2_recalc_irq(sh2); @@ -309,7 +309,7 @@ WRITE32_HANDLER( sh2_internal_w ) case 0x04: // TIER, FTCSR, FRC if((mem_mask & 0x00ffffff) != 0) sh2_timer_resync(sh2); -// printf("SH2.%d: TIER write %04x @ %04x\n", cpu_get_index(sh2->device), data >> 16, mem_mask>>16); +// printf("SH2.%s: TIER write %04x @ %04x\n", sh2->device->tag, data >> 16, mem_mask>>16); sh2->m[4] = (sh2->m[4] & ~(ICF|OCFA|OCFB|OVF)) | (old & sh2->m[4] & (ICF|OCFA|OCFB|OVF)); COMBINE_DATA(&sh2->frc); if((mem_mask & 0x00ffffff) != 0) @@ -317,7 +317,7 @@ WRITE32_HANDLER( sh2_internal_w ) sh2_recalc_irq(sh2); break; case 0x05: // OCRx, TCR, TOCR -// printf("SH2.%d: TCR write %08x @ %08x\n", cpu_get_index(sh2->device), data, mem_mask); +// printf("SH2.%s: TCR write %08x @ %08x\n", sh2->device->tag, data, mem_mask); sh2_timer_resync(sh2); if(sh2->m[5] & 0x10) sh2->ocrb = (sh2->ocrb & (~mem_mask >> 16)) | ((data & mem_mask) >> 16); @@ -533,7 +533,7 @@ void sh2_set_frt_input(const device_config *device, int state) sh2_timer_resync(sh2); sh2->icr = sh2->frc; sh2->m[4] |= ICF; - logerror("SH2.%d: ICF activated (%x)\n", cpu_get_index(sh2->device), sh2->pc & AM); + logerror("SH2.%s: ICF activated (%x)\n", sh2->device->tag, sh2->pc & AM); sh2_recalc_irq(sh2); } diff --git a/src/emu/cpu/tms34010/tms34010.c b/src/emu/cpu/tms34010/tms34010.c index f9e6c6ee45e..610a94cd3c6 100644 --- a/src/emu/cpu/tms34010/tms34010.c +++ b/src/emu/cpu/tms34010/tms34010.c @@ -628,7 +628,7 @@ static CPU_INIT( tms34010 ) /* allocate a scanline timer and set it to go off at the start */ tms->scantimer = timer_alloc(device->machine, scanline_callback, tms); - timer_adjust_oneshot(tms->scantimer, attotime_zero, index); + timer_adjust_oneshot(tms->scantimer, attotime_zero, 0); /* allocate the shiftreg */ tms->shiftreg = auto_malloc(SHIFTREG_SIZE); @@ -737,19 +737,13 @@ static TIMER_CALLBACK( internal_interrupt_callback ) { tms34010_state *tms = ptr; int type = param; - int cpunum; /* call through to the CPU to generate the int */ IOREG(tms, REG_INTPEND) |= type; LOG(("TMS34010 '%s' set internal interrupt $%04x\n", tms->device->tag, type)); /* generate triggers so that spin loops can key off them */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] == tms->device) - { - cpu_triggerint(machine->cpu[cpunum]); - break; - } + cpu_triggerint(tms->device); } @@ -893,8 +887,7 @@ static TIMER_CALLBACK( scanline_callback ) tms34010_state *tms = ptr; const rectangle *current_visarea; int vsblnk, veblnk, vtotal; - int vcount = param >> 8; - int cpunum = param & 0xff; + int vcount = param; int enabled; int master; @@ -1025,7 +1018,7 @@ static TIMER_CALLBACK( scanline_callback ) /* note that we add !master (0 or 1) as a attoseconds value; this makes no practical difference */ /* but helps ensure that masters are updated first before slaves */ - timer_adjust_oneshot(tms->scantimer, attotime_add_attoseconds(video_screen_get_time_until_pos(tms->screen, vcount, 0), !master), cpunum | (vcount << 8)); + timer_adjust_oneshot(tms->scantimer, attotime_add_attoseconds(video_screen_get_time_until_pos(tms->screen, vcount, 0), !master), vcount); } @@ -1068,23 +1061,19 @@ VIDEO_UPDATE( tms340x0 ) pen_t blackpen = get_black_pen(screen->machine); tms34010_display_params params; tms34010_state *tms = NULL; - int cpunum = -1; + const device_config *cpu; int x; /* find the owning CPU */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(screen->machine->cpu); cpunum++) + for (cpu = screen->machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) { - const device_config *cpudevice = screen->machine->cpu[cpunum]; - if (cpudevice != NULL) + cpu_type type = cpu_get_type(cpu); + if (type == CPU_TMS34010 || type == CPU_TMS34020) { - const cpu_class_header *classdata = cpudevice->classtoken; - if (classdata->cputype == CPU_TMS34010 || classdata->cputype == CPU_TMS34020) - { - tms = cpudevice->token; - if (tms->config != NULL && tms->config->scanline_callback != NULL && tms->screen == screen) - break; - tms = NULL; - } + tms = cpu->token; + if (tms->config != NULL && tms->config->scanline_callback != NULL && tms->screen == screen) + break; + tms = NULL; } } if (tms == NULL) @@ -1259,7 +1248,7 @@ WRITE16_HANDLER( tms34010_io_register_w ) } // if (LOG_CONTROL_REGS) -// logerror("CPU#%d@%08X: %s = %04X (%d)\n", cpunum, cpu_get_pc(space->cpu), ioreg_name[offset], IOREG(tms, offset), video_screen_get_vpos(tms->screen)); +// logerror("%s: %s = %04X (%d)\n", cpuexec_describe_context(tms->device->machine), ioreg_name[offset], IOREG(tms, offset), video_screen_get_vpos(tms->screen)); } @@ -1296,7 +1285,7 @@ WRITE16_HANDLER( tms34020_io_register_w ) IOREG(tms, offset) = data; // if (LOG_CONTROL_REGS) -// logerror("CPU#%d@%08X: %s = %04X (%d)\n", cpunum, cpu_get_pc(space->cpu), ioreg020_name[offset], IOREG(tms, offset), video_screen_get_vpos(tms->screen)); +// logerror("%s: %s = %04X (%d)\n", cpuexec_describe_context(device->machine), ioreg020_name[offset], IOREG(tms, offset), video_screen_get_vpos(tms->screen)); switch (offset) { @@ -1455,7 +1444,7 @@ READ16_HANDLER( tms34010_io_register_r ) int result, total; // if (LOG_CONTROL_REGS) -// logerror("CPU#%d@%08X: read %s\n", cpunum, cpu_get_pc(space->cpu), ioreg_name[offset]); +// logerror("%s: read %s\n", cpuexec_describe_context(device->machine), ioreg_name[offset]); switch (offset) { @@ -1498,7 +1487,7 @@ READ16_HANDLER( tms34020_io_register_r ) int result, total; // if (LOG_CONTROL_REGS) -// logerror("CPU#%d@%08X: read %s\n", cpunum, cpu_get_pc(space->cpu), ioreg_name[offset]); +// logerror("%s: read %s\n", cpuexec_describe_context(device->machine), ioreg_name[offset]); switch (offset) { diff --git a/src/emu/cpu/z80/z80daisy.c b/src/emu/cpu/z80/z80daisy.c index 3e17ad0cd8e..0a3b380e9bf 100644 --- a/src/emu/cpu/z80/z80daisy.c +++ b/src/emu/cpu/z80/z80daisy.c @@ -6,8 +6,7 @@ ***************************************************************************/ -#include "cpuintrf.h" -#include "mame.h" +#include "driver.h" #include "z80daisy.h" diff --git a/src/emu/cpuexec.c b/src/emu/cpuexec.c index 9165b6fea16..42756437040 100644 --- a/src/emu/cpuexec.c +++ b/src/emu/cpuexec.c @@ -59,10 +59,8 @@ struct _cpu_input_data typedef struct _cpu_class_data cpu_class_data; struct _cpu_class_data { - /* this item must remain first */ - cpu_class_header header; /* header containing public data */ - /* cycle counting and executing */ + int profiler; /* profiler tag */ int * icount; /* pointer to the icount */ int cycles_running; /* number of cycles we are executing */ int cycles_stolen; /* number of cycles we artificially stole */ @@ -111,10 +109,6 @@ struct _cpuexec_private FUNCTION PROTOTYPES ***************************************************************************/ -static void cpuexec_exit(running_machine *machine); -static void cpuexec_reset(running_machine *machine); - -static void cpu_timers_init(running_machine *machine); static void update_clock_information(const device_config *device); static void compute_perfect_interleave(running_machine *machine); static void on_vblank(const device_config *device, void *param, int vblank_state); @@ -132,18 +126,16 @@ static void register_save_states(const device_config *device); ***************************************************************************/ /*------------------------------------------------- - get_safe_classtoken - makes sure that the - passed in device is, in fact, a CPU, and - return the class token + cpu_get_class_data - return a pointer to + the class data -------------------------------------------------*/ -INLINE cpu_class_data *get_safe_classtoken(const device_config *device) +INLINE cpu_class_data *cpu_get_class_data(const device_config *device) { assert(device != NULL); - assert(device->classtoken != NULL); assert(device->class == DEVICE_CLASS_CPU_CHIP); - - return (cpu_class_data *)device->classtoken; + assert(device->token != NULL); + return (cpu_class_data *)cpu_get_class_header(device) - 1; } @@ -154,7 +146,7 @@ INLINE cpu_class_data *get_safe_classtoken(const device_config *device) INLINE void suspend_until_trigger(const device_config *device, int trigger, int eatcycles) { - cpu_class_data *classdata = get_safe_classtoken(device); + cpu_class_data *classdata = cpu_get_class_data(device); /* suspend the CPU immediately if it's not already */ cpu_suspend(device, SUSPEND_REASON_TRIGGER, eatcycles); @@ -169,35 +161,6 @@ INLINE void suspend_until_trigger(const device_config *device, int trigger, int CORE CPU EXECUTION ***************************************************************************/ -/*------------------------------------------------- - cpuexec_create_cpu_device - temporary - function to allocate a fake CPU device for - each CPU --------------------------------------------------*/ - -static DEVICE_GET_INFO( cpuclass ) -{ - cpu_class_data *classdata = device->classtoken; - (*classdata->header.get_info)(device, state, (cpuinfo *)info); -} - -const device_config *cpuexec_create_cpu_device(const cpu_config *config) -{ - device_config *device; - - /* create a fake device for the CPU -- this will be done automatically in the future */ - device = malloc_or_die(sizeof(*device) + strlen(config->tag)); - memset(device, 0, sizeof(*device)); - strcpy(device->tag, config->tag); - device->type = DEVICE_GET_INFO_NAME(cpuclass); - device->class = DEVICE_CLASS_CPU_CHIP; - device->inline_config = (void *)config; - device->static_config = config->reset_param; - - return device; -} - - /*------------------------------------------------- cpuexec_init - initialize internal states of all CPUs @@ -205,150 +168,20 @@ const device_config *cpuexec_create_cpu_device(const cpu_config *config) void cpuexec_init(running_machine *machine) { - int cpunum; + int numscreens = video_screen_count(machine->config); + attoseconds_t refresh_attosecs; + int ipf; /* allocate global state */ machine->cpuexec_data = auto_malloc(sizeof(*machine->cpuexec_data)); memset(machine->cpuexec_data, 0, sizeof(*machine->cpuexec_data)); - /* loop over all our CPUs */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->config->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) - { - device_config *device = (device_config *)machine->cpu[cpunum]; - const cpu_config *config = device->inline_config; - cpu_type cputype = config->type; - cpu_class_data *classdata; - int num_regs; - int line; - - /* allocate memory for our class state */ - classdata = auto_malloc(sizeof(*classdata)); - memset(classdata, 0, sizeof(*classdata)); - - /* fill in the header */ - classdata->header = *cputype_get_header_template(cputype); - - /* make the device run */ - device->started = FALSE; - device->machine = machine; - device->region = memory_region(machine, device->tag); - device->regionbytes = memory_region_length(machine, device->tag); - device->token = auto_malloc(cputype_get_context_size(cputype)); - memset(device->token, 0, cputype_get_context_size(cputype)); - device->classtoken = classdata; - - /* fill in the input states and IRQ callback information */ - for (line = 0; line < ARRAY_LENGTH(classdata->input); line++) - { - cpu_input_data *inputline = &classdata->input[line]; - /* vector and curvector are initialized later */ - inputline->curstate = CLEAR_LINE; - inputline->qindex = 0; - } - - /* fill in the suspend states */ - classdata->suspend = SUSPEND_REASON_RESET; - classdata->inttrigger = cpunum + TRIGGER_INT; - - /* fill in the clock and timing information */ - classdata->clock = (UINT64)config->clock * classdata->header.clock_multiplier / classdata->header.clock_divider; - classdata->clockscale = 1.0; - - /* allocate timers if we need them */ - if (config->vblank_interrupts_per_frame > 1) - classdata->partial_frame_timer = timer_alloc(machine, trigger_partial_frame_interrupt, device); - if (config->timed_interrupt_period != 0) - classdata->timedint_timer = timer_alloc(machine, trigger_periodic_interrupt, device); - - /* initialize this CPU */ - num_regs = state_save_get_reg_count(machine); - cpu_init(device, cpunum, classdata->clock, standard_irq_callback); - num_regs = state_save_get_reg_count(machine) - num_regs; - - /* fetch post-initialization data */ - classdata->icount = cpu_get_icount_ptr(device); - for (line = 0; line < ARRAY_LENGTH(classdata->input); line++) - { - cpu_input_data *inputline = &classdata->input[line]; - inputline->vector = cpu_get_default_irq_vector(device); - inputline->curvector = inputline->vector; - } - update_clock_information(device); - - /* if no state registered for saving, we can't save */ - if (num_regs == 0) - { - logerror("CPU #%d (%s) did not register any state to save!\n", cpunum, cputype_get_name(cputype)); - if (machine->gamedrv->flags & GAME_SUPPORTS_SAVE) - fatalerror("CPU #%d (%s) did not register any state to save!", cpunum, cputype_get_name(cputype)); - } - - /* register some internal states as well */ - register_save_states(device); - } - - add_reset_callback(machine, cpuexec_reset); - add_exit_callback(machine, cpuexec_exit); -} - - -/*------------------------------------------------- - cpuexec_reset - reset CPU states on a soft - reset --------------------------------------------------*/ - -static void cpuexec_reset(running_machine *machine) -{ - int cpunum; - - /* initialize the various timers */ - cpu_timers_init(machine); - - /* first pass over CPUs */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) - { - const device_config *device = machine->cpu[cpunum]; - const cpu_config *config = device->inline_config; - cpu_class_data *classdata = device->classtoken; - int line; - - /* enable all CPUs (except for disabled CPUs) */ - if (!(config->flags & CPU_DISABLE)) - cpu_resume(device, SUSPEND_ANY_REASON); - else - cpu_suspend(device, SUSPEND_REASON_DISABLE, 1); - - /* reset the total number of cycles */ - classdata->totalcycles = 0; - - /* then reset the CPU directly */ - cpu_reset(device); - - /* reset the interrupt vectors and queues */ - for (line = 0; line < ARRAY_LENGTH(classdata->input); line++) - { - cpu_input_data *inputline = &classdata->input[line]; - inputline->vector = cpu_get_default_irq_vector(device); - inputline->qindex = 0; - } - } -} - - -/*------------------------------------------------- - cpuexec_exit - cleanup all CPUs on exit --------------------------------------------------*/ - -static void cpuexec_exit(running_machine *machine) -{ - int cpunum; - - /* shut down the CPU cores */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) - cpu_exit(machine->cpu[cpunum]); + /* set the core scheduling quantum */ + ipf = machine->config->cpu_slices_per_frame; + if (ipf <= 0) + ipf = 1; + refresh_attosecs = (numscreens == 0) ? HZ_TO_ATTOSECONDS(60) : video_screen_get_frame_period(machine->primary_screen).attoseconds; + timer_add_scheduling_quantum(machine, refresh_attosecs / ipf, attotime_never); } @@ -363,25 +196,25 @@ void cpuexec_timeslice(running_machine *machine) cpuexec_private *global = machine->cpuexec_data; attotime target = timer_next_fire_time(machine); attotime base = timer_get_time(machine); - int cpunum, ran; + const device_config *cpu; + int ran; LOG(("------------------\n")); LOG(("cpu_timeslice: target = %s\n", attotime_string(target, 9))); /* apply pending suspension changes */ - for (cpunum = 0; machine->cpu[cpunum] != NULL; cpunum++) + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) { - cpu_class_data *classdata = machine->cpu[cpunum]->classtoken; + cpu_class_data *classdata = cpu_get_class_data(cpu); classdata->suspend = classdata->nextsuspend; classdata->nextsuspend &= ~SUSPEND_REASON_TIMESLICE; classdata->eatcycles = classdata->nexteatcycles; } /* loop over non-suspended CPUs */ - for (cpunum = 0; machine->cpu[cpunum] != NULL; cpunum++) + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) { - const device_config *cpu = machine->cpu[cpunum]; - cpu_class_data *classdata = cpu->classtoken; + cpu_class_data *classdata = cpu_get_class_data(cpu); if (classdata->suspend == 0) { attotime delta = attotime_sub(target, classdata->localtime); @@ -389,12 +222,12 @@ void cpuexec_timeslice(running_machine *machine) { /* compute how long to run */ classdata->cycles_running = div_64x32(delta.attoseconds >> classdata->divshift, classdata->divisor); - LOG((" cpu %d: %d cycles\n", cpunum, classdata->cycles_running)); + LOG((" cpu '%s': %d cycles\n", cpu->tag, classdata->cycles_running)); - profiler_mark(PROFILER_CPU1 + cpunum); + profiler_mark(classdata->profiler); /* note that this global variable cycles_stolen can be modified */ - /* via the call to the cpunum_execute */ + /* via the call to cpu_execute */ classdata->cycles_stolen = 0; global->executingcpu = cpu; if (!call_debugger) @@ -431,9 +264,9 @@ void cpuexec_timeslice(running_machine *machine) global->executingcpu = NULL; /* update the local times of all CPUs */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu) && machine->cpu[cpunum] != NULL; cpunum++) + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) { - cpu_class_data *classdata = machine->cpu[cpunum]->classtoken; + cpu_class_data *classdata = cpu_get_class_data(cpu); /* if we're suspended and counting, process */ if (classdata->suspend != 0 && classdata->eatcycles && attotime_compare(classdata->localtime, target) < 0) @@ -442,7 +275,7 @@ void cpuexec_timeslice(running_machine *machine) /* compute how long to run */ classdata->cycles_running = div_64x32(delta.attoseconds >> classdata->divshift, classdata->divisor); - LOG((" cpu %d: %d cycles (suspended)\n", cpunum, classdata->cycles_running)); + LOG((" cpu '%s': %d cycles (suspended)\n", cpu->tag, classdata->cycles_running)); classdata->totalcycles += classdata->cycles_running; classdata->localtime = attotime_add_attoseconds(classdata->localtime, classdata->cycles_running * classdata->attoseconds_per_cycle); @@ -459,28 +292,6 @@ void cpuexec_timeslice(running_machine *machine) } - -/*************************************************************************** - GLOBAL HELPERS -***************************************************************************/ - -/*------------------------------------------------- - cputag_get_cpu - return a pointer to the given - CPU by tag --------------------------------------------------*/ - -const device_config *cputag_get_cpu(running_machine *machine, const char *tag) -{ - int cpunum; - - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL && strcmp(tag, machine->cpu[cpunum]->tag) == 0) - return machine->cpu[cpunum]; - - return NULL; -} - - /*------------------------------------------------- cpuexec_boost_interleave - temporarily boosts the interleave factor @@ -495,6 +306,24 @@ void cpuexec_boost_interleave(running_machine *machine, attotime timeslice_time, } + +/*************************************************************************** + GLOBAL HELPERS +***************************************************************************/ + +/*------------------------------------------------- + cpuexec_abort_timeslice - abort execution + for the current timeslice +-------------------------------------------------*/ + +void cpuexec_abort_timeslice(running_machine *machine) +{ + const device_config *executingcpu = machine->cpuexec_data->executingcpu; + if (executingcpu != NULL) + cpu_abort_timeslice(executingcpu); +} + + /*------------------------------------------------- cpuexec_describe_context - return a string describing which CPUs are currently executing @@ -517,6 +346,279 @@ const char *cpuexec_describe_context(running_machine *machine) +/*************************************************************************** + VIDEO SCREEN DEVICE INTERFACE +***************************************************************************/ + +/*------------------------------------------------- + device_start_cpu - device start callback +-------------------------------------------------*/ + +static DEVICE_START( cpu ) +{ + int index = cpu_get_index(device); + cpu_class_header *header; + cpu_class_data *classdata; + const cpu_config *config; + cpu_init_func init; + int spacenum, line; + int num_regs; + + /* validate some basic stuff */ + assert(device != NULL); + assert(device->inline_config != NULL); + assert(device->machine != NULL); + assert(device->machine->config != NULL); + + /* get pointers to our data */ + config = device->inline_config; + header = cpu_get_class_header(device); + classdata = cpu_get_class_data(device); + + /* add ourself to the global array */ + if (index < ARRAY_LENGTH(device->machine->cpu)) + device->machine->cpu[index] = device; + + /* build the header */ + header->debug = NULL; + for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) + header->space[spacenum] = memory_find_address_space(device, spacenum); + + header->set_info = (cpu_set_info_func)cpu_get_info_fct(device, CPUINFO_PTR_SET_INFO); + header->execute = (cpu_execute_func)cpu_get_info_fct(device, CPUINFO_PTR_EXECUTE); + header->burn = (cpu_burn_func)cpu_get_info_fct(device, CPUINFO_PTR_BURN); + header->translate = (cpu_translate_func)cpu_get_info_fct(device, CPUINFO_PTR_TRANSLATE); + header->disassemble = (cpu_disassemble_func)cpu_get_info_fct(device, CPUINFO_PTR_DISASSEMBLE); + header->dasm_override = NULL; + + header->clock_divider = cpu_get_clock_divider(device); + header->clock_multiplier = cpu_get_clock_multiplier(device); + + /* fill in the input states and IRQ callback information */ + for (line = 0; line < ARRAY_LENGTH(classdata->input); line++) + { + cpu_input_data *inputline = &classdata->input[line]; + /* vector and curvector are initialized later */ + inputline->curstate = CLEAR_LINE; + inputline->qindex = 0; + } + + /* fill in the suspend states */ + classdata->profiler = index + PROFILER_CPU1; + classdata->suspend = SUSPEND_REASON_RESET; + classdata->inttrigger = index + TRIGGER_INT; + + /* fill in the clock and timing information */ + classdata->clock = (UINT64)config->clock * header->clock_multiplier / header->clock_divider; + classdata->clockscale = 1.0; + + /* allocate timers if we need them */ + if (config->vblank_interrupts_per_frame > 1) + classdata->partial_frame_timer = timer_alloc(device->machine, trigger_partial_frame_interrupt, (void *)device); + if (config->timed_interrupt_period != 0) + classdata->timedint_timer = timer_alloc(device->machine, trigger_periodic_interrupt, (void *)device); + + /* initialize this CPU */ + num_regs = state_save_get_reg_count(device->machine); + init = (cpu_init_func)cpu_get_info_fct(device, CPUINFO_PTR_INIT); + (*init)(device, index, classdata->clock, standard_irq_callback); + num_regs = state_save_get_reg_count(device->machine) - num_regs; + + /* fetch post-initialization data */ + classdata->icount = cpu_get_icount_ptr(device); + for (line = 0; line < ARRAY_LENGTH(classdata->input); line++) + { + cpu_input_data *inputline = &classdata->input[line]; + inputline->vector = cpu_get_default_irq_vector(device); + inputline->curvector = inputline->vector; + } + update_clock_information(device); + + /* if no state registered for saving, we can't save */ + if (num_regs == 0) + { + logerror("CPU '%s' did not register any state to save!\n", cpu_get_name(device)); + if (device->machine->gamedrv->flags & GAME_SUPPORTS_SAVE) + fatalerror("CPU '%s' did not register any state to save!", cpu_get_name(device)); + } + + /* register some internal states as well */ + register_save_states(device); + + return DEVICE_START_OK; +} + + +/*------------------------------------------------- + device_reset_cpu - device reset callback +-------------------------------------------------*/ + +static DEVICE_RESET( cpu ) +{ + cpu_class_data *classdata = cpu_get_class_data(device); + const cpu_config *config = device->inline_config; + cpu_reset_func reset; + int line; + + /* enable all CPUs (except for disabled CPUs) */ + if (!(config->flags & CPU_DISABLE)) + cpu_resume(device, SUSPEND_ANY_REASON); + else + cpu_suspend(device, SUSPEND_REASON_DISABLE, 1); + + /* reset the total number of cycles */ + classdata->totalcycles = 0; + + /* then reset the CPU directly */ + reset = (cpu_reset_func)cpu_get_info_fct(device, CPUINFO_PTR_RESET); + if (reset != NULL) + (*reset)(device); + + /* reset the interrupt vectors and queues */ + for (line = 0; line < ARRAY_LENGTH(classdata->input); line++) + { + cpu_input_data *inputline = &classdata->input[line]; + inputline->vector = cpu_get_default_irq_vector(device); + inputline->qindex = 0; + } + + /* reconfingure VBLANK interrupts */ + if (config->vblank_interrupts_per_frame > 0 || config->vblank_interrupt_screen != NULL) + { + const device_config *screen; + + /* get the screen that will trigger the VBLANK */ + + /* new style - use screen tag directly */ + if (config->vblank_interrupt_screen != NULL) + screen = devtag_get_device(device->machine, VIDEO_SCREEN, config->vblank_interrupt_screen); + + /* old style 'hack' setup - use screen #0 */ + else + screen = video_screen_first(device->machine->config); + + assert(screen != NULL); + video_screen_register_vblank_callback(screen, on_vblank, NULL); + } + + /* reconfigure periodic interrupts */ + if (config->timed_interrupt_period != 0) + { + attotime timedint_period = UINT64_ATTOTIME_TO_ATTOTIME(config->timed_interrupt_period); + assert(classdata->timedint_timer != NULL); + timer_adjust_periodic(classdata->timedint_timer, timedint_period, 0, timedint_period); + } +} + + +/*------------------------------------------------- + device_stop_cpu - device stop callback +-------------------------------------------------*/ + +static DEVICE_STOP( cpu ) +{ + cpu_exit_func exit; + + /* call the CPU's exit function if present */ + exit = (cpu_exit_func)cpu_get_info_fct(device, CPUINFO_PTR_EXIT); + if (exit != NULL) + (*exit)(device); +} + + +/*------------------------------------------------- + cpu_set_info - device set info callback +-------------------------------------------------*/ + +static DEVICE_SET_INFO( cpu ) +{ + cpu_class_header *header = cpu_get_class_header(device); + cpu_set_info_func set_info; + cpuinfo cinfo; + + /* if we are live and have a header, save ourself a call */ + if (header != NULL) + set_info = header->set_info; + else + set_info = (cpu_set_info_func)cpu_get_info_fct(device, CPUINFO_PTR_SET_INFO); + + switch (state) + { + /* no parameters to set */ + + default: + /* integer data */ + if (state >= DEVINFO_INT_FIRST && state <= DEVINFO_INT_LAST) + { + cinfo.i = info->i; + (*set_info)(device, state, &cinfo); + } + + /* pointer data */ + else if ((state >= DEVINFO_PTR_FIRST && state <= DEVINFO_PTR_LAST) || + (state >= DEVINFO_FCT_FIRST && state <= DEVINFO_FCT_LAST) || + (state >= DEVINFO_STR_FIRST && state <= DEVINFO_STR_LAST)) + { + cinfo.p = info->p; + (*set_info)(device, state, &cinfo); + } + break; + } +} + + +/*------------------------------------------------- + cpu_get_info - device get info + callback +-------------------------------------------------*/ + +DEVICE_GET_INFO( cpu ) +{ + const cpu_config *config = (device != NULL) ? device->inline_config : NULL; + cpuinfo cinfo = { 0 }; + + switch (state) + { + /* --- the following bits of info are returned as 64-bit signed integers --- */ + case DEVINFO_INT_TOKEN_BYTES: + cinfo.i = 0; + (*config->type)(device, CPUINFO_INT_CONTEXT_SIZE, &cinfo); + info->i = cinfo.i + sizeof(cpu_class_data) + sizeof(cpu_class_header); + break; + + case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(cpu_config); break; + case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_CPU_CHIP; break; + + /* --- the following bits of info are returned as pointers to data or functions --- */ + case DEVINFO_FCT_SET_INFO: info->set_info = DEVICE_SET_INFO_NAME(cpu); break; + case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(cpu); break; + case DEVINFO_FCT_STOP: info->stop = DEVICE_STOP_NAME(cpu); break; + case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(cpu); break; + + default: + /* integer data */ + if (state >= DEVINFO_INT_FIRST && state <= DEVINFO_INT_LAST) + { + cinfo.i = info->i; + (*config->type)(device, state, &cinfo); + info->i = cinfo.i; + } + + /* pointer data */ + else if ((state >= DEVINFO_PTR_FIRST && state <= DEVINFO_PTR_LAST) || + (state >= DEVINFO_FCT_FIRST && state <= DEVINFO_FCT_LAST) || + (state >= DEVINFO_STR_FIRST && state <= DEVINFO_STR_LAST)) + { + cinfo.p = info->p; + (*config->type)(device, state, &cinfo); + info->p = cinfo.p; + } + break; + } +} + + + /*************************************************************************** CPU SCHEDULING ***************************************************************************/ @@ -528,7 +630,7 @@ const char *cpuexec_describe_context(running_machine *machine) void cpu_suspend(const device_config *device, int reason, int eatcycles) { - cpu_class_data *classdata = get_safe_classtoken(device); + cpu_class_data *classdata = cpu_get_class_data(device); /* set the suspend reason and eat cycles flag */ classdata->nextsuspend |= reason; @@ -546,7 +648,7 @@ void cpu_suspend(const device_config *device, int reason, int eatcycles) void cpu_resume(const device_config *device, int reason) { - cpu_class_data *classdata = get_safe_classtoken(device); + cpu_class_data *classdata = cpu_get_class_data(device); /* clear the suspend reason and eat cycles flag */ classdata->nextsuspend &= ~reason; @@ -575,7 +677,7 @@ int cpu_is_executing(const device_config *device) int cpu_is_suspended(const device_config *device, int reason) { - cpu_class_data *classdata = get_safe_classtoken(device); + cpu_class_data *classdata = cpu_get_class_data(device); /* return true if the given reason is indicated */ return ((classdata->nextsuspend & reason) != 0); @@ -594,7 +696,7 @@ int cpu_is_suspended(const device_config *device, int reason) int cpu_get_clock(const device_config *device) { - cpu_class_data *classdata = get_safe_classtoken(device); + cpu_class_data *classdata = cpu_get_class_data(device); /* return the current clock value */ return classdata->clock; @@ -608,7 +710,7 @@ int cpu_get_clock(const device_config *device) void cpu_set_clock(const device_config *device, int clock) { - cpu_class_data *classdata = get_safe_classtoken(device); + cpu_class_data *classdata = cpu_get_class_data(device); /* set the clock and update the information */ classdata->clock = clock; @@ -623,7 +725,7 @@ void cpu_set_clock(const device_config *device, int clock) double cpu_get_clockscale(const device_config *device) { - cpu_class_data *classdata = get_safe_classtoken(device); + cpu_class_data *classdata = cpu_get_class_data(device); /* return the current clock scale factor */ return classdata->clockscale; @@ -637,7 +739,7 @@ double cpu_get_clockscale(const device_config *device) void cpu_set_clockscale(const device_config *device, double clockscale) { - cpu_class_data *classdata = get_safe_classtoken(device); + cpu_class_data *classdata = cpu_get_class_data(device); /* set the scale factor and update the information */ classdata->clockscale = clockscale; @@ -652,7 +754,7 @@ void cpu_set_clockscale(const device_config *device, double clockscale) attotime cpu_clocks_to_attotime(const device_config *device, UINT64 clocks) { - cpu_class_data *classdata = get_safe_classtoken(device); + cpu_class_data *classdata = cpu_get_class_data(device); if (clocks < classdata->cycles_per_second) return attotime_make(0, clocks * classdata->attoseconds_per_cycle); else @@ -671,7 +773,7 @@ attotime cpu_clocks_to_attotime(const device_config *device, UINT64 clocks) UINT64 cpu_attotime_to_clocks(const device_config *device, attotime duration) { - cpu_class_data *classdata = get_safe_classtoken(device); + cpu_class_data *classdata = cpu_get_class_data(device); return mulu_32x32(duration.seconds, classdata->cycles_per_second) + (UINT64)duration.attoseconds * (UINT64)classdata->attoseconds_per_cycle; } @@ -688,7 +790,7 @@ UINT64 cpu_attotime_to_clocks(const device_config *device, attotime duration) attotime cpu_get_local_time(const device_config *device) { - cpu_class_data *classdata = get_safe_classtoken(device); + cpu_class_data *classdata = cpu_get_class_data(device); attotime result; /* if we're active, add in the time from the current slice */ @@ -725,7 +827,7 @@ attotime cpuexec_override_local_time(running_machine *machine, attotime default_ UINT64 cpu_get_total_cycles(const device_config *device) { - cpu_class_data *classdata = get_safe_classtoken(device); + cpu_class_data *classdata = cpu_get_class_data(device); if (device == device->machine->cpuexec_data->executingcpu) return classdata->totalcycles + classdata->cycles_running - *classdata->icount; @@ -741,7 +843,7 @@ UINT64 cpu_get_total_cycles(const device_config *device) void cpu_eat_cycles(const device_config *device, int cycles) { - cpu_class_data *classdata = get_safe_classtoken(device); + cpu_class_data *classdata = cpu_get_class_data(device); /* ignore if not the executing CPU */ if (device != device->machine->cpuexec_data->executingcpu) @@ -760,7 +862,7 @@ void cpu_eat_cycles(const device_config *device, int cycles) void cpu_adjust_icount(const device_config *device, int delta) { - cpu_class_data *classdata = get_safe_classtoken(device); + cpu_class_data *classdata = cpu_get_class_data(device); /* ignore if not the executing CPU */ if (device != device->machine->cpuexec_data->executingcpu) @@ -778,7 +880,7 @@ void cpu_adjust_icount(const device_config *device, int delta) void cpu_abort_timeslice(const device_config *device) { - cpu_class_data *classdata = get_safe_classtoken(device); + cpu_class_data *classdata = cpu_get_class_data(device); int delta; /* ignore if not the executing CPU */ @@ -796,19 +898,6 @@ void cpu_abort_timeslice(const device_config *device) } -/*------------------------------------------------- - cpuexec_abort_timeslice - abort execution - for the current timeslice --------------------------------------------------*/ - -void cpuexec_abort_timeslice(running_machine *machine) -{ - const device_config *executingcpu = machine->cpuexec_data->executingcpu; - if (executingcpu != NULL) - cpu_abort_timeslice(executingcpu); -} - - /*************************************************************************** SYNCHRONIZATION HELPERS @@ -857,7 +946,7 @@ void cpu_spinuntil_trigger(const device_config *device, int trigger) void cpu_spinuntil_int(const device_config *device) { - cpu_class_data *classdata = get_safe_classtoken(device); + cpu_class_data *classdata = cpu_get_class_data(device); /* suspend until the given trigger fires */ suspend_until_trigger(device, classdata->inttrigger, TRUE); @@ -893,20 +982,20 @@ void cpu_spinuntil_time(const device_config *device, attotime duration) void cpuexec_trigger(running_machine *machine, int trigger) { - int cpunum; - + const device_config *cpu; + /* look for suspended CPUs waiting for this trigger and unsuspend them */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu) && machine->cpu[cpunum] != NULL; cpunum++) + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) { - cpu_class_data *classdata = machine->cpu[cpunum]->classtoken; + cpu_class_data *classdata = cpu_get_class_data(cpu); /* if we're executing, for an immediate abort */ - cpu_abort_timeslice(machine->cpu[cpunum]); + cpu_abort_timeslice(cpu); /* see if this is a matching trigger */ if (classdata->suspend != 0 && classdata->trigger == trigger) { - cpu_resume(machine->cpu[cpunum], SUSPEND_REASON_TRIGGER); + cpu_resume(cpu, SUSPEND_REASON_TRIGGER); classdata->trigger = 0; } } @@ -931,7 +1020,7 @@ void cpuexec_triggertime(running_machine *machine, int trigger, attotime duratio void cpu_triggerint(const device_config *device) { - cpu_class_data *classdata = get_safe_classtoken(device); + cpu_class_data *classdata = cpu_get_class_data(device); /* signal this CPU's interrupt trigger */ cpuexec_trigger(device->machine, classdata->inttrigger); @@ -951,7 +1040,7 @@ void cpu_triggerint(const device_config *device) void cpu_set_input_line(const device_config *device, int line, int state) { - cpu_class_data *classdata = get_safe_classtoken(device); + cpu_class_data *classdata = cpu_get_class_data(device); int vector = (line >= 0 && line < MAX_INPUT_LINES) ? classdata->input[line].vector : 0xff; cpu_set_input_line_and_vector(device, line, state, vector); } @@ -965,13 +1054,13 @@ void cpu_set_input_line(const device_config *device, int line, int state) void cpu_set_input_line_vector(const device_config *device, int line, int vector) { - cpu_class_data *classdata = get_safe_classtoken(device); + cpu_class_data *classdata = cpu_get_class_data(device); if (line >= 0 && line < MAX_INPUT_LINES) { classdata->input[line].vector = vector; return; } - LOG(("cpunum_set_input_line_vector CPU '%s' line %d > max input lines\n", device->tag, line)); + LOG(("cpu_set_input_line_vector CPU '%s' line %d > max input lines\n", device->tag, line)); } @@ -983,7 +1072,7 @@ void cpu_set_input_line_vector(const device_config *device, int line, int vector void cpu_set_input_line_and_vector(const device_config *device, int line, int state, int vector) { - cpu_class_data *classdata = get_safe_classtoken(device); + cpu_class_data *classdata = cpu_get_class_data(device); /* catch errors where people use PULSE_LINE for CPUs that don't support it */ if (state == PULSE_LINE && line != INPUT_LINE_NMI && line != INPUT_LINE_RESET) @@ -995,7 +1084,7 @@ void cpu_set_input_line_and_vector(const device_config *device, int line, int st INT32 input_event = (state & 0xff) | (vector << 8); int event_index = inputline->qindex++; - LOG(("cpunum_set_input_line_and_vector('%s',%d,%d,%02x)\n", device->tag, line, state, vector)); + LOG(("cpu_set_input_line_and_vector('%s',%d,%d,%02x)\n", device->tag, line, state, vector)); /* if we're full of events, flush the queue and log a message */ if (event_index >= ARRAY_LENGTH(inputline->queue)) @@ -1026,7 +1115,7 @@ void cpu_set_input_line_and_vector(const device_config *device, int line, int st void cpu_set_irq_callback(const device_config *device, cpu_irq_callback callback) { - cpu_class_data *classdata = get_safe_classtoken(device); + cpu_class_data *classdata = cpu_get_class_data(device); classdata->driver_irq = callback; } @@ -1043,7 +1132,7 @@ void cpu_set_irq_callback(const device_config *device, cpu_irq_callback callback int cpu_getiloops(const device_config *device) { - cpu_class_data *classdata = get_safe_classtoken(device); + cpu_class_data *classdata = cpu_get_class_data(device); return classdata->iloops; } @@ -1053,61 +1142,6 @@ int cpu_getiloops(const device_config *device) INTERNAL FUNCTIONS ***************************************************************************/ -/*------------------------------------------------- - cpu_timers_init - set up all the core timers --------------------------------------------------*/ - -static void cpu_timers_init(running_machine *machine) -{ - int numscreens = video_screen_count(machine->config); - attoseconds_t refresh_attosecs; - int cpunum, ipf; - - /* set the core scheduling quantum */ - ipf = machine->config->cpu_slices_per_frame; - if (ipf <= 0) - ipf = 1; - refresh_attosecs = (numscreens == 0) ? HZ_TO_ATTOSECONDS(60) : video_screen_get_frame_period(machine->primary_screen).attoseconds; - timer_add_scheduling_quantum(machine, refresh_attosecs / ipf, attotime_never); - - /* register the interrupt handler callbacks */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) - { - const device_config *device = machine->cpu[cpunum]; - const cpu_config *config = device->inline_config; - cpu_class_data *classdata = device->classtoken; - - /* VBLANK interrupts */ - if (config->vblank_interrupts_per_frame > 0) - { - const device_config *screen; - - /* get the screen that will trigger the VBLANK */ - - /* new style - use screen tag directly */ - if (config->vblank_interrupts_per_frame == 1) - screen = device_list_find_by_tag(machine->config->devicelist, VIDEO_SCREEN, config->vblank_interrupt_screen); - - /* old style 'hack' setup - use screen #0 */ - else - screen = device_list_first(machine->config->devicelist, VIDEO_SCREEN); - - assert(screen != NULL); - video_screen_register_vblank_callback(screen, on_vblank, NULL); - } - - /* periodic interrupts */ - if (config->timed_interrupt_period != 0) - { - attotime timedint_period = attotime_make(0, config->timed_interrupt_period); - assert(classdata->timedint_timer != NULL); - timer_adjust_periodic(classdata->timedint_timer, timedint_period, cpunum, timedint_period); - } - } -} - - /*------------------------------------------------- update_clock_information - recomputes clock information for the specified CPU @@ -1115,7 +1149,7 @@ static void cpu_timers_init(running_machine *machine) static void update_clock_information(const device_config *device) { - cpu_class_data *classdata = device->classtoken; + cpu_class_data *classdata = cpu_get_class_data(device); INT64 attos; /* recompute cps and spc */ @@ -1144,19 +1178,19 @@ static void update_clock_information(const device_config *device) static void compute_perfect_interleave(running_machine *machine) { - if (machine->cpu[0] != NULL && machine->cpu[0]->classtoken != NULL) + if (machine->cpu[0] != NULL && machine->cpu[0]->token != NULL) { - cpu_class_data *classdata = machine->cpu[0]->classtoken; - attoseconds_t smallest = classdata->attoseconds_per_cycle * cputype_get_min_cycles(machine->config->cpu[0].type); + cpu_class_data *classdata = cpu_get_class_data(machine->cpu[0]); + attoseconds_t smallest = classdata->attoseconds_per_cycle * cputype_get_min_cycles(cpu_get_type(machine->cpu[0])); attoseconds_t perfect = ATTOSECONDS_PER_SECOND - 1; - int cpunum; + const device_config *cpu; /* start with a huge time factor and find the 2nd smallest cycle time */ - for (cpunum = 1; cpunum < ARRAY_LENGTH(machine->cpu) && machine->cpu[cpunum] != NULL; cpunum++) - if (machine->cpu[cpunum] != NULL && machine->cpu[cpunum]->classtoken != NULL) + for (cpu = machine->cpu[0]->typenext; cpu != NULL; cpu = cpu->typenext) + if (cpu->token != NULL) { - cpu_class_data *classdata = machine->cpu[cpunum]->classtoken; - attoseconds_t curtime = classdata->attoseconds_per_cycle * cputype_get_min_cycles(machine->config->cpu[cpunum].type); + cpu_class_data *classdata = cpu_get_class_data(cpu); + attoseconds_t curtime = classdata->attoseconds_per_cycle * cpu_get_min_cycles(cpu); /* find the 2nd smallest cycle interval */ if (curtime < smallest) @@ -1186,49 +1220,47 @@ static void on_vblank(const device_config *device, void *param, int vblank_state /* VBLANK starting */ if (vblank_state) { - int cpunum; - + const device_config *cpu; + /* find any CPUs that have this screen as their VBLANK interrupt source */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(device->machine->cpu); cpunum++) - if (device->machine->cpu[cpunum] != NULL) + for (cpu = device->machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + { + const cpu_config *config = cpu->inline_config; + cpu_class_data *classdata = cpu_get_class_data(cpu); + int cpu_interested; + + /* start the interrupt counter */ + if (!(classdata->suspend & SUSPEND_REASON_DISABLE)) + classdata->iloops = 0; + else + classdata->iloops = -1; + + /* the hack style VBLANK decleration always uses the first screen */ + if (config->vblank_interrupts_per_frame > 1) + cpu_interested = TRUE; + + /* for new style declaration, we need to compare the tags */ + else if (config->vblank_interrupt_screen != NULL) + cpu_interested = (strcmp(config->vblank_interrupt_screen, device->tag) == 0); + + /* no VBLANK interrupt, not interested */ + else + cpu_interested = FALSE; + + /* if interested, call the interrupt handler */ + if (cpu_interested) { - const device_config *cpudevice = device->machine->cpu[cpunum]; - const cpu_config *config = cpudevice->inline_config; - cpu_class_data *classdata = cpudevice->classtoken; - int cpu_interested; + if (!(classdata->suspend & (SUSPEND_REASON_HALT | SUSPEND_REASON_RESET | SUSPEND_REASON_DISABLE))) + (*config->vblank_interrupt)(cpu); - /* start the interrupt counter */ - if (!(classdata->suspend & SUSPEND_REASON_DISABLE)) - classdata->iloops = 0; - else - classdata->iloops = -1; - - /* the hack style VBLANK decleration always uses the first screen */ - if (config->vblank_interrupts_per_frame > 1) - cpu_interested = TRUE; - - /* for new style decleration, we need to compare the tags */ - else if (config->vblank_interrupts_per_frame == 1) - cpu_interested = (strcmp(config->vblank_interrupt_screen, device->tag) == 0); - - /* no VBLANK interrupt, not interested */ - else - cpu_interested = FALSE; - - /* if interested, call the interrupt handler */ - if (cpu_interested) + /* if we have more than one interrupt per frame, start the timer now to trigger the rest of them */ + if (config->vblank_interrupts_per_frame > 1 && !(classdata->suspend & SUSPEND_REASON_DISABLE)) { - if (!(classdata->suspend & (SUSPEND_REASON_HALT | SUSPEND_REASON_RESET | SUSPEND_REASON_DISABLE))) - (*config->vblank_interrupt)(cpudevice); - - /* if we have more than one interrupt per frame, start the timer now to trigger the rest of them */ - if (config->vblank_interrupts_per_frame > 1 && !(classdata->suspend & SUSPEND_REASON_DISABLE)) - { - classdata->partial_frame_period = attotime_div(video_screen_get_frame_period(device->machine->primary_screen), config->vblank_interrupts_per_frame); - timer_adjust_oneshot(classdata->partial_frame_timer, classdata->partial_frame_period, cpunum); - } + classdata->partial_frame_period = attotime_div(video_screen_get_frame_period(device->machine->primary_screen), config->vblank_interrupts_per_frame); + timer_adjust_oneshot(classdata->partial_frame_timer, classdata->partial_frame_period, 0); } } + } } } @@ -1242,7 +1274,7 @@ static TIMER_CALLBACK( trigger_partial_frame_interrupt ) { const device_config *device = ptr; const cpu_config *config = device->inline_config; - cpu_class_data *classdata = device->classtoken; + cpu_class_data *classdata = cpu_get_class_data(device); if (classdata->iloops == 0) classdata->iloops = config->vblank_interrupts_per_frame; @@ -1294,7 +1326,7 @@ static TIMER_CALLBACK( triggertime_callback ) static TIMER_CALLBACK( empty_event_queue ) { const device_config *device = ptr; - cpu_class_data *classdata = device->classtoken; + cpu_class_data *classdata = cpu_get_class_data(device); cpu_input_data *inputline = &classdata->input[param]; int curevent; @@ -1320,7 +1352,7 @@ static TIMER_CALLBACK( empty_event_queue ) /* if we're clearing the line that was previously asserted, or if we're just */ /* pulsing the line, reset the CPU */ if ((state == CLEAR_LINE && cpu_is_suspended(device, SUSPEND_REASON_RESET)) || state == PULSE_LINE) - cpu_reset(device); + device_reset(device); /* if we're clearing the line, make sure the CPU is not halted */ cpu_resume(device, SUSPEND_REASON_RESET); @@ -1346,8 +1378,6 @@ static TIMER_CALLBACK( empty_event_queue ) switch (state) { case PULSE_LINE: - /* temporary: PULSE_LINE only makes sense for NMI lines on Z80 */ - assert(classdata->header.cputype != CPU_Z80 || param == INPUT_LINE_NMI); cpu_set_info_int(device, CPUINFO_INT_INPUT_STATE + param, ASSERT_LINE); cpu_set_info_int(device, CPUINFO_INT_INPUT_STATE + param, CLEAR_LINE); break; @@ -1385,7 +1415,7 @@ static TIMER_CALLBACK( empty_event_queue ) static IRQ_CALLBACK( standard_irq_callback ) { - cpu_class_data *classdata = device->classtoken; + cpu_class_data *classdata = cpu_get_class_data(device); cpu_input_data *inputline = &classdata->input[irqline]; int vector = inputline->curvector; @@ -1418,7 +1448,7 @@ static IRQ_CALLBACK( standard_irq_callback ) static void register_save_states(const device_config *device) { - cpu_class_data *classdata = device->classtoken; + cpu_class_data *classdata = cpu_get_class_data(device); int line; state_save_register_device_item(device, 0, classdata->suspend); diff --git a/src/emu/cpuexec.h b/src/emu/cpuexec.h index 7b4bf284c9f..92ba823804b 100644 --- a/src/emu/cpuexec.h +++ b/src/emu/cpuexec.h @@ -49,31 +49,86 @@ enum TYPE DEFINITIONS ***************************************************************************/ +typedef void (*cpu_interrupt_func)(const device_config *device); + + /* CPU description for drivers */ typedef struct _cpu_config cpu_config; struct _cpu_config { - cpu_type type; /* index for the CPU type */ - int flags; /* flags; see #defines below */ - int clock; /* in Hertz */ - const addrmap_token *address_map[ADDRESS_SPACES][2]; /* 2 memory maps per address space */ - void (*vblank_interrupt)(const device_config *device); /* for interrupts tied to VBLANK */ - int vblank_interrupts_per_frame;/* usually 1 */ - const char * vblank_interrupt_screen; /* the screen that causes the VBLANK interrupt */ - void (*timed_interrupt)(const device_config *device); /* for interrupts not tied to VBLANK */ - attoseconds_t timed_interrupt_period; /* period for periodic interrupts */ - const void * reset_param; /* parameter for cpu_reset */ - const char * tag; + cpu_type type; /* index for the CPU type */ + UINT32 flags; /* flags; see #defines below */ + UINT32 clock; /* in Hertz */ + const addrmap_token *address_map[ADDRESS_SPACES]; /* 2 memory maps per address space */ + const addrmap_token *address_map2[ADDRESS_SPACES]; /* 2 memory maps per address space */ + cpu_interrupt_func vblank_interrupt; /* for interrupts tied to VBLANK */ + int vblank_interrupts_per_frame;/* usually 1 */ + const char * vblank_interrupt_screen; /* the screen that causes the VBLANK interrupt */ + cpu_interrupt_func timed_interrupt; /* for interrupts not tied to VBLANK */ + UINT64 timed_interrupt_period; /* period for periodic interrupts */ }; +/*************************************************************************** + CPU DEVICE CONFIGURATION MACROS +***************************************************************************/ + +#define MDRV_CPU_ADD(_tag, _type, _clock) \ + MDRV_DEVICE_ADD(_tag, CPU) \ + MDRV_DEVICE_CONFIG_DATA32(cpu_config, type, CPU_##_type) \ + MDRV_DEVICE_CONFIG_DATA32(cpu_config, clock, _clock) + +#define MDRV_CPU_REMOVE(_tag) \ + MDRV_DEVICE_REMOVE(_tag, CPU) + +#define MDRV_CPU_MODIFY(_tag) \ + MDRV_DEVICE_MODIFY(_tag, CPU) + +#define MDRV_CPU_REPLACE(_tag, _type, _clock) \ + MDRV_DEVICE_REMOVE(_tag, CPU) \ + MDRV_DEVICE_ADD(_tag, CPU) \ + MDRV_DEVICE_CONFIG_DATA32(cpu_config, type, CPU_##_type) \ + MDRV_DEVICE_CONFIG_DATA32(cpu_config, clock, _clock) + +#define MDRV_CPU_FLAGS(_flags) \ + MDRV_DEVICE_CONFIG_DATA32(cpu_config, flags, _flags) + +#define MDRV_CPU_CONFIG(_config) \ + MDRV_DEVICE_CONFIG(_config) + +#define MDRV_CPU_PROGRAM_MAP(_map1, _map2) \ + MDRV_DEVICE_CONFIG_DATAPTR_ARRAY(cpu_config, address_map, ADDRESS_SPACE_PROGRAM, ADDRESS_MAP_NAME(_map1)) \ + MDRV_DEVICE_CONFIG_DATAPTR_ARRAY(cpu_config, address_map2, ADDRESS_SPACE_PROGRAM, ADDRESS_MAP_NAME(_map2)) + +#define MDRV_CPU_DATA_MAP(_map1, _map2) \ + MDRV_DEVICE_CONFIG_DATAPTR_ARRAY(cpu_config, address_map, ADDRESS_SPACE_DATA, ADDRESS_MAP_NAME(_map1)) \ + MDRV_DEVICE_CONFIG_DATAPTR_ARRAY(cpu_config, address_map2, ADDRESS_SPACE_DATA, ADDRESS_MAP_NAME(_map2)) + +#define MDRV_CPU_IO_MAP(_map1, _map2) \ + MDRV_DEVICE_CONFIG_DATAPTR_ARRAY(cpu_config, address_map, ADDRESS_SPACE_IO, ADDRESS_MAP_NAME(_map1)) \ + MDRV_DEVICE_CONFIG_DATAPTR_ARRAY(cpu_config, address_map2, ADDRESS_SPACE_IO, ADDRESS_MAP_NAME(_map2)) + +#define MDRV_CPU_VBLANK_INT(_tag, _func) \ + MDRV_DEVICE_CONFIG_DATAPTR(cpu_config, vblank_interrupt, _func) \ + MDRV_DEVICE_CONFIG_DATAPTR(cpu_config, vblank_interrupt_screen, _tag) \ + MDRV_DEVICE_CONFIG_DATA32(cpu_config, vblank_interrupts_per_frame, 0) + +#define MDRV_CPU_PERIODIC_INT(_func, _rate) \ + MDRV_DEVICE_CONFIG_DATAPTR(cpu_config, timed_interrupt, _func) \ + MDRV_DEVICE_CONFIG_DATA64(cpu_config, timed_interrupt_period, UINT64_ATTOTIME_IN_HZ(_rate)) + + + /*************************************************************************** MACROS ***************************************************************************/ #define INTERRUPT_GEN(func) void func(const device_config *device) +/* return a pointer to the given CPU by tag */ +#define cputag_get_cpu(mach, tag) devtag_get_device(mach, CPU, tag) + /* helpers for using machine/cputag instead of cpu objects */ #define cputag_suspend(mach, tag, reason, eat) cpu_suspend(cputag_get_cpu(mach, tag), reason, eat) #define cputag_resume(mach, tag, reason) cpu_resume(cputag_get_cpu(mach, tag), reason) @@ -96,9 +151,6 @@ struct _cpu_config /* ----- core CPU execution ----- */ -/* temporary function to allocate a fake CPU device for each CPU */ -const device_config *cpuexec_create_cpu_device(const cpu_config *config); - /* prepare CPUs for execution */ void cpuexec_init(running_machine *machine); @@ -110,10 +162,15 @@ void cpuexec_boost_interleave(running_machine *machine, attotime timeslice_time, -/* ----- global helpers ----- */ +/* ----- CPU device interface ----- */ -/* return a pointer to the given CPU by tag */ -const device_config *cputag_get_cpu(running_machine *machine, const char *tag); +/* device get info callback */ +#define CPU DEVICE_GET_INFO_NAME(cpu) +DEVICE_GET_INFO( cpu ); + + + +/* ----- global helpers ----- */ /* abort execution for the current timeslice */ void cpuexec_abort_timeslice(running_machine *machine); @@ -227,4 +284,23 @@ void cpu_set_input_line_and_vector(const device_config *cpu, int line, int state void cpu_set_irq_callback(const device_config *cpu, cpu_irq_callback callback); + +/*************************************************************************** + INLINE FUNCTIONS +***************************************************************************/ + + +/*------------------------------------------------- + cpu_get_type - return the type of the + specified CPU +-------------------------------------------------*/ + +INLINE cpu_type cpu_get_type(const device_config *device) +{ + const cpu_config *config = device->inline_config; + return config->type; +} + + + #endif /* __CPUEXEC_H__ */ diff --git a/src/emu/cpuintrf.c b/src/emu/cpuintrf.c index 1635f6cc661..8d3978c8225 100644 --- a/src/emu/cpuintrf.c +++ b/src/emu/cpuintrf.c @@ -35,882 +35,10 @@ -/*************************************************************************** - PROTOTYPES FOR ALL CPU ENTRY POINTS -***************************************************************************/ - -CPU_GET_INFO( dummy ); -CPU_GET_INFO( z80 ); -CPU_GET_INFO( z180 ); -CPU_GET_INFO( i8080 ); -CPU_GET_INFO( i8085 ); -CPU_GET_INFO( m6502 ); -CPU_GET_INFO( m65c02 ); -CPU_GET_INFO( m65sc02 ); -CPU_GET_INFO( m65ce02 ); -CPU_GET_INFO( m6509 ); -CPU_GET_INFO( m6510 ); -CPU_GET_INFO( m6510t ); -CPU_GET_INFO( m7501 ); -CPU_GET_INFO( m8502 ); -CPU_GET_INFO( n2a03 ); -CPU_GET_INFO( deco16 ); -CPU_GET_INFO( m4510 ); -CPU_GET_INFO( h6280 ); -CPU_GET_INFO( i8086 ); -CPU_GET_INFO( i8088 ); -CPU_GET_INFO( i80186 ); -CPU_GET_INFO( i80188 ); -CPU_GET_INFO( i80286 ); -CPU_GET_INFO( v20 ); -CPU_GET_INFO( v25 ); -CPU_GET_INFO( v30 ); -CPU_GET_INFO( v33 ); -CPU_GET_INFO( v35 ); -CPU_GET_INFO( v60 ); -CPU_GET_INFO( v70 ); -CPU_GET_INFO( i8035 ); -CPU_GET_INFO( i8048 ); -CPU_GET_INFO( i8648 ); -CPU_GET_INFO( i8748 ); -CPU_GET_INFO( mb8884 ); -CPU_GET_INFO( i8039 ); -CPU_GET_INFO( i8049 ); -CPU_GET_INFO( i8749 ); -CPU_GET_INFO( n7751 ); -CPU_GET_INFO( m58715 ); -CPU_GET_INFO( i8041 ); -CPU_GET_INFO( i8741 ); -CPU_GET_INFO( i8042 ); -CPU_GET_INFO( i8242 ); -CPU_GET_INFO( i8742 ); -CPU_GET_INFO( i8031 ); -CPU_GET_INFO( i8032 ); -CPU_GET_INFO( i8051 ); -CPU_GET_INFO( i8052 ); -CPU_GET_INFO( i8751 ); -CPU_GET_INFO( i8752 ); -CPU_GET_INFO( i80c31 ); -CPU_GET_INFO( i80c32 ); -CPU_GET_INFO( i80c51 ); -CPU_GET_INFO( i80c52 ); -CPU_GET_INFO( i87c51 ); -CPU_GET_INFO( i87c52 ); -CPU_GET_INFO( at89c4051 ); -CPU_GET_INFO( ds5002fp ); -CPU_GET_INFO( m6800 ); -CPU_GET_INFO( m6801 ); -CPU_GET_INFO( m6802 ); -CPU_GET_INFO( m6803 ); -CPU_GET_INFO( m6808 ); -CPU_GET_INFO( hd63701 ); -CPU_GET_INFO( nsc8105 ); -CPU_GET_INFO( m6805 ); -CPU_GET_INFO( m68705 ); -CPU_GET_INFO( hd63705 ); -CPU_GET_INFO( hd6309 ); -CPU_GET_INFO( m6809 ); -CPU_GET_INFO( m6809e ); -CPU_GET_INFO( konami ); -CPU_GET_INFO( m68000 ); -CPU_GET_INFO( m68008 ); -CPU_GET_INFO( m68010 ); -CPU_GET_INFO( m68ec020 ); -CPU_GET_INFO( m68020 ); -CPU_GET_INFO( m68040 ); -CPU_GET_INFO( t11 ); -CPU_GET_INFO( s2650 ); -CPU_GET_INFO( tms34010 ); -CPU_GET_INFO( tms34020 ); -CPU_GET_INFO( ti990_10 ); -CPU_GET_INFO( tms9900 ); -CPU_GET_INFO( tms9980a ); -CPU_GET_INFO( tms9995 ); -CPU_GET_INFO( z8000 ); -CPU_GET_INFO( tms32010 ); -CPU_GET_INFO( tms32025 ); -CPU_GET_INFO( tms32026 ); -CPU_GET_INFO( tms32031 ); -CPU_GET_INFO( tms32032 ); -CPU_GET_INFO( tms32051 ); -CPU_GET_INFO( ccpu ); -CPU_GET_INFO( adsp2100 ); -CPU_GET_INFO( adsp2101 ); -CPU_GET_INFO( adsp2104 ); -CPU_GET_INFO( adsp2105 ); -CPU_GET_INFO( adsp2115 ); -CPU_GET_INFO( adsp2181 ); -CPU_GET_INFO( psxcpu ); -CPU_GET_INFO( asap ); -CPU_GET_INFO( upd7810 ); -CPU_GET_INFO( upd7807 ); -CPU_GET_INFO( upd7801 ); -CPU_GET_INFO( upd78c05 ); -CPU_GET_INFO( upd78c06 ); -CPU_GET_INFO( jaguargpu ); -CPU_GET_INFO( jaguardsp ); -CPU_GET_INFO( cquestsnd ); -CPU_GET_INFO( cquestrot ); -CPU_GET_INFO( cquestlin ); -CPU_GET_INFO( r3000be ); -CPU_GET_INFO( r3000le ); -CPU_GET_INFO( r3041be ); -CPU_GET_INFO( r3041le ); -CPU_GET_INFO( r4600be ); -CPU_GET_INFO( r4600le ); -CPU_GET_INFO( r4650be ); -CPU_GET_INFO( r4650le ); -CPU_GET_INFO( r4700be ); -CPU_GET_INFO( r4700le ); -CPU_GET_INFO( r5000be ); -CPU_GET_INFO( r5000le ); -CPU_GET_INFO( qed5271be ); -CPU_GET_INFO( qed5271le ); -CPU_GET_INFO( rm7000be ); -CPU_GET_INFO( rm7000le ); -CPU_GET_INFO( arm ); -CPU_GET_INFO( arm7 ); -CPU_GET_INFO( sh1 ); -CPU_GET_INFO( sh2 ); -CPU_GET_INFO( sh4 ); -CPU_GET_INFO( dsp32c ); -CPU_GET_INFO( pic16C54 ); -CPU_GET_INFO( pic16C55 ); -CPU_GET_INFO( pic16C56 ); -CPU_GET_INFO( pic16C57 ); -CPU_GET_INFO( pic16C58 ); -CPU_GET_INFO( g65816 ); -CPU_GET_INFO( spc700 ); -CPU_GET_INFO( e116t ); -CPU_GET_INFO( e116xt ); -CPU_GET_INFO( e116xs ); -CPU_GET_INFO( e116xsr ); -CPU_GET_INFO( e132n ); -CPU_GET_INFO( e132t ); -CPU_GET_INFO( e132xn ); -CPU_GET_INFO( e132xt ); -CPU_GET_INFO( e132xs ); -CPU_GET_INFO( e132xsr ); -CPU_GET_INFO( gms30c2116 ); -CPU_GET_INFO( gms30c2132 ); -CPU_GET_INFO( gms30c2216 ); -CPU_GET_INFO( gms30c2232 ); -CPU_GET_INFO( i386 ); -CPU_GET_INFO( i486 ); -CPU_GET_INFO( pentium ); -CPU_GET_INFO( mediagx ); -CPU_GET_INFO( i960 ); -CPU_GET_INFO( h8_3002 ); -CPU_GET_INFO( h8_3007 ); -CPU_GET_INFO( h8_3044 ); -CPU_GET_INFO( h8_3334 ); -CPU_GET_INFO( v810 ); -CPU_GET_INFO( m37702 ); -CPU_GET_INFO( m37710 ); -CPU_GET_INFO( ppc403ga ); -CPU_GET_INFO( ppc403gcx ); -CPU_GET_INFO( ppc601 ); -CPU_GET_INFO( ppc602 ); -CPU_GET_INFO( ppc603 ); -CPU_GET_INFO( ppc603e ); -CPU_GET_INFO( ppc603r ); -CPU_GET_INFO( ppc604 ); -CPU_GET_INFO( mpc8240 ); -CPU_GET_INFO( SE3208 ); -CPU_GET_INFO( mc68hc11 ); -CPU_GET_INFO( adsp21062 ); -CPU_GET_INFO( dsp56k ); -CPU_GET_INFO( rsp ); -CPU_GET_INFO( alpha8201 ); -CPU_GET_INFO( alpha8301 ); -CPU_GET_INFO( cdp1802 ); -CPU_GET_INFO( cop401 ); -CPU_GET_INFO( cop410 ); -CPU_GET_INFO( cop411 ); -CPU_GET_INFO( cop402 ); -CPU_GET_INFO( cop420 ); -CPU_GET_INFO( cop421 ); -CPU_GET_INFO( cop422 ); -CPU_GET_INFO( cop404 ); -CPU_GET_INFO( cop424 ); -CPU_GET_INFO( cop425 ); -CPU_GET_INFO( cop426 ); -CPU_GET_INFO( cop444 ); -CPU_GET_INFO( cop445 ); -CPU_GET_INFO( tmp90840 ); -CPU_GET_INFO( tmp90841 ); -CPU_GET_INFO( tmp91640 ); -CPU_GET_INFO( tmp91641 ); -CPU_GET_INFO( apexc ); -CPU_GET_INFO( cp1610 ); -CPU_GET_INFO( f8 ); -CPU_GET_INFO( lh5801 ); -CPU_GET_INFO( pdp1 ); -CPU_GET_INFO( saturn ); -CPU_GET_INFO( sc61860 ); -CPU_GET_INFO( tx0_64kw ); -CPU_GET_INFO( tx0_8kw ); -CPU_GET_INFO( lr35902 ); -CPU_GET_INFO( tms7000 ); -CPU_GET_INFO( tms7000_exl ); -CPU_GET_INFO( sm8500 ); -CPU_GET_INFO( v30mz ); -CPU_GET_INFO( mb8841 ); -CPU_GET_INFO( mb8842 ); -CPU_GET_INFO( mb8843 ); -CPU_GET_INFO( mb8844 ); -CPU_GET_INFO( mb86233 ); -CPU_GET_INFO( ssp1601 ); -CPU_GET_INFO( minx ); -CPU_GET_INFO( cxd8661r ); - - - -/*************************************************************************** - MASTER CPU LIST -***************************************************************************/ - -static const struct -{ - int cputype; - cpu_get_info_func get_info; -} cpuintrf_map[] = -{ - { CPU_DUMMY, CPU_GET_INFO_NAME(dummy) }, -#if (HAS_Z80) - { CPU_Z80, CPU_GET_INFO_NAME(z80) }, -#endif -#if (HAS_Z180) - { CPU_Z180, CPU_GET_INFO_NAME(z180) }, -#endif -#if (HAS_8080) - { CPU_8080, CPU_GET_INFO_NAME(i8080) }, -#endif -#if (HAS_8085A) - { CPU_8085A, CPU_GET_INFO_NAME(i8085) }, -#endif -#if (HAS_M6502) - { CPU_M6502, CPU_GET_INFO_NAME(m6502) }, -#endif -#if (HAS_M65C02) - { CPU_M65C02, CPU_GET_INFO_NAME(m65c02) }, -#endif -#if (HAS_M65SC02) - { CPU_M65SC02, CPU_GET_INFO_NAME(m65sc02) }, -#endif -#if (HAS_M65CE02) - { CPU_M65CE02, CPU_GET_INFO_NAME(m65ce02) }, -#endif -#if (HAS_M6509) - { CPU_M6509, CPU_GET_INFO_NAME(m6509) }, -#endif -#if (HAS_M6510) - { CPU_M6510, CPU_GET_INFO_NAME(m6510) }, -#endif -#if (HAS_M6510T) - { CPU_M6510T, CPU_GET_INFO_NAME(m6510t) }, -#endif -#if (HAS_M7501) - { CPU_M7501, CPU_GET_INFO_NAME(m7501) }, -#endif -#if (HAS_M8502) - { CPU_M8502, CPU_GET_INFO_NAME(m8502) }, -#endif -#if (HAS_N2A03) - { CPU_N2A03, CPU_GET_INFO_NAME(n2a03) }, -#endif -#if (HAS_DECO16) - { CPU_DECO16, CPU_GET_INFO_NAME(deco16) }, -#endif -#if (HAS_M4510) - { CPU_M4510, CPU_GET_INFO_NAME(m4510) }, -#endif -#if (HAS_H6280) - { CPU_H6280, CPU_GET_INFO_NAME(h6280) }, -#endif -#if (HAS_I8086) - { CPU_I8086, CPU_GET_INFO_NAME(i8086) }, -#endif -#if (HAS_I8088) - { CPU_I8088, CPU_GET_INFO_NAME(i8088) }, -#endif -#if (HAS_I80186) - { CPU_I80186, CPU_GET_INFO_NAME(i80186) }, -#endif -#if (HAS_I80188) - { CPU_I80188, CPU_GET_INFO_NAME(i80188) }, -#endif -#if (HAS_I80286) - { CPU_I80286, CPU_GET_INFO_NAME(i80286) }, -#endif -#if (HAS_V20) - { CPU_V20, CPU_GET_INFO_NAME(v20) }, -#endif -#if (HAS_V25) - { CPU_V25, CPU_GET_INFO_NAME(v25) }, -#endif -#if (HAS_V30) - { CPU_V30, CPU_GET_INFO_NAME(v30) }, -#endif -#if (HAS_V33) - { CPU_V33, CPU_GET_INFO_NAME(v33) }, -#endif -#if (HAS_V35) - { CPU_V35, CPU_GET_INFO_NAME(v35) }, -#endif -#if (HAS_V60) - { CPU_V60, CPU_GET_INFO_NAME(v60) }, -#endif -#if (HAS_V70) - { CPU_V70, CPU_GET_INFO_NAME(v70) }, -#endif -#if (HAS_I8035) - { CPU_I8035, CPU_GET_INFO_NAME(i8035) }, -#endif -#if (HAS_I8041) - { CPU_I8041, CPU_GET_INFO_NAME(i8041) }, -#endif -#if (HAS_I8048) - { CPU_I8048, CPU_GET_INFO_NAME(i8048) }, -#endif -#if (HAS_I8648) - { CPU_I8648, CPU_GET_INFO_NAME(i8648) }, -#endif -#if (HAS_I8748) - { CPU_I8748, CPU_GET_INFO_NAME(i8748) }, -#endif -#if (HAS_MB8884) - { CPU_MB8884, CPU_GET_INFO_NAME(mb8884) }, -#endif -#if (HAS_N7751) - { CPU_N7751, CPU_GET_INFO_NAME(n7751) }, -#endif -#if (HAS_I8039) - { CPU_I8039, CPU_GET_INFO_NAME(i8039) }, -#endif -#if (HAS_I8049) - { CPU_I8049, CPU_GET_INFO_NAME(i8049) }, -#endif -#if (HAS_I8749) - { CPU_I8749, CPU_GET_INFO_NAME(i8749) }, -#endif -#if (HAS_M58715) - { CPU_M58715, CPU_GET_INFO_NAME(m58715) }, -#endif -#if (HAS_I8041) - { CPU_I8041, CPU_GET_INFO_NAME(i8041) }, -#endif -#if (HAS_I8741) - { CPU_I8741, CPU_GET_INFO_NAME(i8741) }, -#endif -#if (HAS_I8042) - { CPU_I8042, CPU_GET_INFO_NAME(i8042) }, -#endif -#if (HAS_I8242) - { CPU_I8242, CPU_GET_INFO_NAME(i8242) }, -#endif -#if (HAS_I8742) - { CPU_I8742, CPU_GET_INFO_NAME(i8742) }, -#endif -#if (HAS_I8031) - { CPU_I8031, CPU_GET_INFO_NAME(i8031) }, -#endif -#if (HAS_I8032) - { CPU_I8032, CPU_GET_INFO_NAME(i8032) }, -#endif -#if (HAS_I8051) - { CPU_I8051, CPU_GET_INFO_NAME(i8051) }, -#endif -#if (HAS_I8052) - { CPU_I8052, CPU_GET_INFO_NAME(i8052) }, -#endif -#if (HAS_I8751) - { CPU_I8751, CPU_GET_INFO_NAME(i8751) }, -#endif -#if (HAS_I8752) - { CPU_I8752, CPU_GET_INFO_NAME(i8752) }, -#endif -#if (HAS_I80C31) - { CPU_I80C31, CPU_GET_INFO_NAME(i80c31) }, -#endif -#if (HAS_I80C32) - { CPU_I80C32, CPU_GET_INFO_NAME(i80c32) }, -#endif -#if (HAS_I80C51) - { CPU_I80C51, CPU_GET_INFO_NAME(i80c51) }, -#endif -#if (HAS_I80C52) - { CPU_I80C52, CPU_GET_INFO_NAME(i80c52) }, -#endif -#if (HAS_I87C51) - { CPU_I87C51, CPU_GET_INFO_NAME(i87c51) }, -#endif -#if (HAS_I87C52) - { CPU_I87C52, CPU_GET_INFO_NAME(i87c52) }, -#endif -#if (HAS_AT89C4051) - { CPU_AT89C4051, CPU_GET_INFO_NAME(at89c4051) }, -#endif -#if (HAS_DS5002FP) - { CPU_DS5002FP, CPU_GET_INFO_NAME(ds5002fp) }, -#endif -#if (HAS_M6800) - { CPU_M6800, CPU_GET_INFO_NAME(m6800) }, -#endif -#if (HAS_M6801) - { CPU_M6801, CPU_GET_INFO_NAME(m6801) }, -#endif -#if (HAS_M6802) - { CPU_M6802, CPU_GET_INFO_NAME(m6802) }, -#endif -#if (HAS_M6803) - { CPU_M6803, CPU_GET_INFO_NAME(m6803) }, -#endif -#if (HAS_M6808) - { CPU_M6808, CPU_GET_INFO_NAME(m6808) }, -#endif -#if (HAS_HD63701) - { CPU_HD63701, CPU_GET_INFO_NAME(hd63701) }, -#endif -#if (HAS_NSC8105) - { CPU_NSC8105, CPU_GET_INFO_NAME(nsc8105) }, -#endif -#if (HAS_M6805) - { CPU_M6805, CPU_GET_INFO_NAME(m6805) }, -#endif -#if (HAS_M68705) - { CPU_M68705, CPU_GET_INFO_NAME(m68705) }, -#endif -#if (HAS_HD63705) - { CPU_HD63705, CPU_GET_INFO_NAME(hd63705) }, -#endif -#if (HAS_HD6309) - { CPU_HD6309, CPU_GET_INFO_NAME(hd6309) }, -#endif -#if (HAS_M6809) - { CPU_M6809, CPU_GET_INFO_NAME(m6809) }, -#endif -#if (HAS_M6809E) - { CPU_M6809E, CPU_GET_INFO_NAME(m6809e) }, -#endif -#if (HAS_KONAMI) - { CPU_KONAMI, CPU_GET_INFO_NAME(konami) }, -#endif -#if (HAS_M680X0) - { CPU_M68000, CPU_GET_INFO_NAME(m68000) }, - { CPU_M68008, CPU_GET_INFO_NAME(m68008) }, - { CPU_M68010, CPU_GET_INFO_NAME(m68010) }, - { CPU_M68EC020, CPU_GET_INFO_NAME(m68ec020) }, - { CPU_M68020, CPU_GET_INFO_NAME(m68020) }, - { CPU_M68040, CPU_GET_INFO_NAME(m68040) }, -#endif -#if (HAS_T11) - { CPU_T11, CPU_GET_INFO_NAME(t11) }, -#endif -#if (HAS_S2650) - { CPU_S2650, CPU_GET_INFO_NAME(s2650) }, -#endif -#if (HAS_TMS340X0) - { CPU_TMS34010, CPU_GET_INFO_NAME(tms34010) }, - { CPU_TMS34020, CPU_GET_INFO_NAME(tms34020) }, -#endif -#if (HAS_TI990_10) - { CPU_TI990_10, CPU_GET_INFO_NAME(ti990_10) }, -#endif -#if (HAS_TMS9900) - { CPU_TMS9900, CPU_GET_INFO_NAME(tms9900) }, -#endif -#if (HAS_TMS9980) - { CPU_TMS9980, CPU_GET_INFO_NAME(tms9980a) }, -#endif -#if (HAS_TMS9995) - { CPU_TMS9995, CPU_GET_INFO_NAME(tms9995) }, -#endif -#if (HAS_Z8000) - { CPU_Z8000, CPU_GET_INFO_NAME(z8000) }, -#endif -#if (HAS_TMS32010) - { CPU_TMS32010, CPU_GET_INFO_NAME(tms32010) }, -#endif -#if (HAS_TMS32025) - { CPU_TMS32025, CPU_GET_INFO_NAME(tms32025) }, -#endif -#if (HAS_TMS32026) - { CPU_TMS32026, CPU_GET_INFO_NAME(tms32026) }, -#endif -#if (HAS_TMS32031) - { CPU_TMS32031, CPU_GET_INFO_NAME(tms32031) }, -#endif -#if (HAS_TMS32032) - { CPU_TMS32032, CPU_GET_INFO_NAME(tms32032) }, -#endif -#if (HAS_TMS32051) - { CPU_TMS32051, CPU_GET_INFO_NAME(tms32051) }, -#endif -#if (HAS_CCPU) - { CPU_CCPU, CPU_GET_INFO_NAME(ccpu) }, -#endif -#if (HAS_ADSP2100) - { CPU_ADSP2100, CPU_GET_INFO_NAME(adsp2100) }, -#endif -#if (HAS_ADSP2101) - { CPU_ADSP2101, CPU_GET_INFO_NAME(adsp2101) }, -#endif -#if (HAS_ADSP2104) - { CPU_ADSP2104, CPU_GET_INFO_NAME(adsp2104) }, -#endif -#if (HAS_ADSP2105) - { CPU_ADSP2105, CPU_GET_INFO_NAME(adsp2105) }, -#endif -#if (HAS_ADSP2115) - { CPU_ADSP2115, CPU_GET_INFO_NAME(adsp2115) }, -#endif -#if (HAS_ADSP2181) - { CPU_ADSP2181, CPU_GET_INFO_NAME(adsp2181) }, -#endif -#if (HAS_PSXCPU) - { CPU_PSXCPU, CPU_GET_INFO_NAME(psxcpu) }, -#endif -#if (HAS_ASAP) - { CPU_ASAP, CPU_GET_INFO_NAME(asap) }, -#endif -#if (HAS_UPD7810) - { CPU_UPD7810, CPU_GET_INFO_NAME(upd7810) }, -#endif -#if (HAS_UPD7807) - { CPU_UPD7807, CPU_GET_INFO_NAME(upd7807) }, -#endif -#if (HAS_UPD7801) - { CPU_UPD7801, CPU_GET_INFO_NAME(upd7801) }, - { CPU_UPD78C05, CPU_GET_INFO_NAME(upd78c05) }, - { CPU_UPD78C06, CPU_GET_INFO_NAME(upd78c06) }, -#endif -#if (HAS_JAGUAR) - { CPU_JAGUARGPU, CPU_GET_INFO_NAME(jaguargpu) }, - { CPU_JAGUARDSP, CPU_GET_INFO_NAME(jaguardsp) }, -#endif -#if (HAS_CUBEQCPU) - { CPU_CQUESTSND, CPU_GET_INFO_NAME(cquestsnd) }, - { CPU_CQUESTROT, CPU_GET_INFO_NAME(cquestrot) }, - { CPU_CQUESTLIN, CPU_GET_INFO_NAME(cquestlin) }, -#endif -#if (HAS_R3000) - { CPU_R3000BE, CPU_GET_INFO_NAME(r3000be) }, - { CPU_R3000LE, CPU_GET_INFO_NAME(r3000le) }, -#endif -#if (HAS_R3041) - { CPU_R3041BE, CPU_GET_INFO_NAME(r3041be) }, - { CPU_R3041LE, CPU_GET_INFO_NAME(r3041le) }, -#endif -#if (HAS_R4600) - { CPU_R4600BE, CPU_GET_INFO_NAME(r4600be) }, - { CPU_R4600LE, CPU_GET_INFO_NAME(r4600le) }, -#endif -#if (HAS_R4650) - { CPU_R4650BE, CPU_GET_INFO_NAME(r4650be) }, - { CPU_R4650LE, CPU_GET_INFO_NAME(r4650le) }, -#endif -#if (HAS_R4700) - { CPU_R4700BE, CPU_GET_INFO_NAME(r4700be) }, - { CPU_R4700LE, CPU_GET_INFO_NAME(r4700le) }, -#endif -#if (HAS_R5000) - { CPU_R5000BE, CPU_GET_INFO_NAME(r5000be) }, - { CPU_R5000LE, CPU_GET_INFO_NAME(r5000le) }, -#endif -#if (HAS_QED5271) - { CPU_QED5271BE, CPU_GET_INFO_NAME(qed5271be) }, - { CPU_QED5271LE, CPU_GET_INFO_NAME(qed5271le) }, -#endif -#if (HAS_RM7000) - { CPU_RM7000BE, CPU_GET_INFO_NAME(rm7000be) }, - { CPU_RM7000LE, CPU_GET_INFO_NAME(rm7000le) }, -#endif -#if (HAS_ARM) - { CPU_ARM, CPU_GET_INFO_NAME(arm) }, -#endif -#if (HAS_ARM7) - { CPU_ARM7, CPU_GET_INFO_NAME(arm7) }, -#endif -#if (HAS_SH1) - { CPU_SH1, CPU_GET_INFO_NAME(sh1) }, -#endif -#if (HAS_SH2) - { CPU_SH2, CPU_GET_INFO_NAME(sh2) }, -#endif -#if (HAS_SH4) - { CPU_SH4, CPU_GET_INFO_NAME(sh4) }, -#endif -#if (HAS_DSP32C) - { CPU_DSP32C, CPU_GET_INFO_NAME(dsp32c) }, -#endif -#if (HAS_PIC16C54) - { CPU_PIC16C54, CPU_GET_INFO_NAME(pic16C54) }, -#endif -#if (HAS_PIC16C55) - { CPU_PIC16C55, CPU_GET_INFO_NAME(pic16C55) }, -#endif -#if (HAS_PIC16C56) - { CPU_PIC16C56, CPU_GET_INFO_NAME(pic16C56) }, -#endif -#if (HAS_PIC16C57) - { CPU_PIC16C57, CPU_GET_INFO_NAME(pic16C57) }, -#endif -#if (HAS_PIC16C58) - { CPU_PIC16C58, CPU_GET_INFO_NAME(pic16C58) }, -#endif -#if (HAS_G65816) - { CPU_G65816, CPU_GET_INFO_NAME(g65816) }, -#endif -#if (HAS_SPC700) - { CPU_SPC700, CPU_GET_INFO_NAME(spc700) }, -#endif -#if (HAS_E116T) - { CPU_E116T, CPU_GET_INFO_NAME(e116t) }, -#endif -#if (HAS_E116XT) - { CPU_E116XT, CPU_GET_INFO_NAME(e116xt) }, -#endif -#if (HAS_E116XS) - { CPU_E116XS, CPU_GET_INFO_NAME(e116xs) }, -#endif -#if (HAS_E116XSR) - { CPU_E116XSR, CPU_GET_INFO_NAME(e116xsr) }, -#endif -#if (HAS_E132N) - { CPU_E132N, CPU_GET_INFO_NAME(e132n) }, -#endif -#if (HAS_E132T) - { CPU_E132T, CPU_GET_INFO_NAME(e132t) }, -#endif -#if (HAS_E132XN) - { CPU_E132XN, CPU_GET_INFO_NAME(e132xn) }, -#endif -#if (HAS_E132XT) - { CPU_E132XT, CPU_GET_INFO_NAME(e132xt) }, -#endif -#if (HAS_E132XS) - { CPU_E132XS, CPU_GET_INFO_NAME(e132xs) }, -#endif -#if (HAS_E132XSR) - { CPU_E132XSR, CPU_GET_INFO_NAME(e132xsr) }, -#endif -#if (HAS_GMS30C2116) - { CPU_GMS30C2116, CPU_GET_INFO_NAME(gms30c2116) }, -#endif -#if (HAS_GMS30C2132) - { CPU_GMS30C2132, CPU_GET_INFO_NAME(gms30c2132) }, -#endif -#if (HAS_GMS30C2216) - { CPU_GMS30C2216, CPU_GET_INFO_NAME(gms30c2216) }, -#endif -#if (HAS_GMS30C2232) - { CPU_GMS30C2232, CPU_GET_INFO_NAME(gms30c2232) }, -#endif -#if (HAS_I386) - { CPU_I386, CPU_GET_INFO_NAME(i386) }, -#endif -#if (HAS_I486) - { CPU_I486, CPU_GET_INFO_NAME(i486) }, -#endif -#if (HAS_PENTIUM) - { CPU_PENTIUM, CPU_GET_INFO_NAME(pentium) }, -#endif -#if (HAS_MEDIAGX) - { CPU_MEDIAGX, CPU_GET_INFO_NAME(mediagx) }, -#endif -#if (HAS_I960) - { CPU_I960, CPU_GET_INFO_NAME(i960) }, -#endif -#if (HAS_H83334) - { CPU_H83334, CPU_GET_INFO_NAME(h8_3334) }, -#endif -#if (HAS_H83002) - { CPU_H83002, CPU_GET_INFO_NAME(h8_3002) }, - { CPU_H83007, CPU_GET_INFO_NAME(h8_3007) }, - { CPU_H83044, CPU_GET_INFO_NAME(h8_3044) }, -#endif -#if (HAS_V810) - { CPU_V810, CPU_GET_INFO_NAME(v810) }, -#endif -#if (HAS_M37702) - { CPU_M37702, CPU_GET_INFO_NAME(m37702) }, -#endif -#if (HAS_M37710) - { CPU_M37710, CPU_GET_INFO_NAME(m37710) }, -#endif -#if (HAS_PPC403GA) - { CPU_PPC403GA, CPU_GET_INFO_NAME(ppc403ga) }, -#endif -#if (HAS_PPC403GCX) - { CPU_PPC403GCX, CPU_GET_INFO_NAME(ppc403gcx) }, -#endif -#if (HAS_PPC601) - { CPU_PPC601, CPU_GET_INFO_NAME(ppc601) }, -#endif -#if (HAS_PPC602) - { CPU_PPC602, CPU_GET_INFO_NAME(ppc602) }, -#endif -#if (HAS_PPC603) - { CPU_PPC603, CPU_GET_INFO_NAME(ppc603) }, -#endif -#if (HAS_PPC603E) - { CPU_PPC603E, CPU_GET_INFO_NAME(ppc603e) }, -#endif -#if (HAS_PPC603R) - { CPU_PPC603R, CPU_GET_INFO_NAME(ppc603r) }, -#endif -#if (HAS_PPC604) - { CPU_PPC604, CPU_GET_INFO_NAME(ppc604) }, -#endif -#if (HAS_MPC8240) - { CPU_MPC8240, CPU_GET_INFO_NAME(mpc8240) }, -#endif -#if (HAS_SE3208) - { CPU_SE3208, CPU_GET_INFO_NAME(SE3208) }, -#endif -#if (HAS_MC68HC11) - { CPU_MC68HC11, CPU_GET_INFO_NAME(mc68hc11) }, -#endif -#if (HAS_ADSP21062) - { CPU_ADSP21062, CPU_GET_INFO_NAME(adsp21062) }, -#endif -#if (HAS_DSP56156) - { CPU_DSP56156, CPU_GET_INFO_NAME(dsp56k) }, -#endif -#if (HAS_RSP) - { CPU_RSP, CPU_GET_INFO_NAME(rsp) }, -#endif -#if (HAS_ALPHA8201) - { CPU_ALPHA8201, CPU_GET_INFO_NAME(alpha8201) }, -#endif -#if (HAS_ALPHA8301) - { CPU_ALPHA8301, CPU_GET_INFO_NAME(alpha8301) }, -#endif -#if (HAS_CDP1802) - { CPU_CDP1802, CPU_GET_INFO_NAME(cdp1802) }, -#endif -#if (HAS_COP401) - { CPU_COP401, CPU_GET_INFO_NAME(cop401) }, -#endif -#if (HAS_COP410) - { CPU_COP410, CPU_GET_INFO_NAME(cop410) }, -#endif -#if (HAS_COP411) - { CPU_COP411, CPU_GET_INFO_NAME(cop411) }, -#endif -#if (HAS_COP402) - { CPU_COP402, CPU_GET_INFO_NAME(cop402) }, -#endif -#if (HAS_COP420) - { CPU_COP420, CPU_GET_INFO_NAME(cop420) }, -#endif -#if (HAS_COP421) - { CPU_COP421, CPU_GET_INFO_NAME(cop421) }, -#endif -#if (HAS_COP422) - { CPU_COP422, CPU_GET_INFO_NAME(cop422) }, -#endif -#if (HAS_COP404) - { CPU_COP404, CPU_GET_INFO_NAME(cop404) }, -#endif -#if (HAS_COP424) - { CPU_COP424, CPU_GET_INFO_NAME(cop424) }, -#endif -#if (HAS_COP425) - { CPU_COP425, CPU_GET_INFO_NAME(cop425) }, -#endif -#if (HAS_COP426) - { CPU_COP426, CPU_GET_INFO_NAME(cop426) }, -#endif -#if (HAS_COP444) - { CPU_COP444, CPU_GET_INFO_NAME(cop444) }, -#endif -#if (HAS_COP445) - { CPU_COP445, CPU_GET_INFO_NAME(cop445) }, -#endif -#if (HAS_TLCS90) - { CPU_TMP90840, CPU_GET_INFO_NAME(tmp90840) }, - { CPU_TMP90841, CPU_GET_INFO_NAME(tmp90841) }, - { CPU_TMP91640, CPU_GET_INFO_NAME(tmp91640) }, - { CPU_TMP91641, CPU_GET_INFO_NAME(tmp91641) }, -#endif -#if (HAS_APEXC) - { CPU_APEXC, CPU_GET_INFO_NAME(apexc) }, -#endif -#if (HAS_CP1610) - { CPU_CP1610, CPU_GET_INFO_NAME(cp1610) }, -#endif -#if (HAS_F8) - { CPU_F8, CPU_GET_INFO_NAME(f8) }, -#endif -#if (HAS_LH5801) - { CPU_LH5801, CPU_GET_INFO_NAME(lh5801) }, -#endif -#if (HAS_PDP1) - { CPU_PDP1, CPU_GET_INFO_NAME(pdp1) }, -#endif -#if (HAS_SATURN) - { CPU_SATURN, CPU_GET_INFO_NAME(saturn) }, -#endif -#if (HAS_SC61860) - { CPU_SC61860, CPU_GET_INFO_NAME(sc61860) }, -#endif -#if (HAS_TX0_64KW) - { CPU_TX0_64KW, CPU_GET_INFO_NAME(tx0_64kw) }, -#endif -#if (HAS_TX0_8KW) - { CPU_TX0_8KW, CPU_GET_INFO_NAME(tx0_8kw) }, -#endif -#if (HAS_LR35902) - { CPU_LR35902, CPU_GET_INFO_NAME(lr35902) }, -#endif -#if (HAS_TMS7000) - { CPU_TMS7000, CPU_GET_INFO_NAME(tms7000) }, -#endif -#if (HAS_TMS7000_EXL) - { CPU_TMS7000_EXL, CPU_GET_INFO_NAME(tms7000_exl) }, -#endif -#if (HAS_SM8500) - { CPU_SM8500, CPU_GET_INFO_NAME(sm8500) }, -#endif -#if (HAS_V30MZ) - { CPU_V30MZ, CPU_GET_INFO_NAME(v30mz) }, -#endif -#if (HAS_MB8841) - { CPU_MB8841, CPU_GET_INFO_NAME(mb8841) }, -#endif -#if (HAS_MB8842) - { CPU_MB8842, CPU_GET_INFO_NAME(mb8842) }, -#endif -#if (HAS_MB8843) - { CPU_MB8843, CPU_GET_INFO_NAME(mb8843) }, -#endif -#if (HAS_MB8844) - { CPU_MB8844, CPU_GET_INFO_NAME(mb8844) }, -#endif -#if (HAS_MB86233) - { CPU_MB86233, CPU_GET_INFO_NAME(mb86233) }, -#endif -#if (HAS_SSP1601) - { CPU_SSP1601, CPU_GET_INFO_NAME(ssp1601) }, -#endif -#if (HAS_MINX) - { CPU_MINX, CPU_GET_INFO_NAME(minx) }, -#endif -#if (HAS_CXD8661R) - { CPU_CXD8661R, CPU_GET_INFO_NAME(cxd8661r) }, -#endif -}; - - - /*************************************************************************** GLOBAL VARIABLES ***************************************************************************/ -static cpu_class_header cpu_type_header[CPU_COUNT]; - static char temp_string_pool[TEMP_STRING_POOL_ENTRIES][MAX_STRING_LENGTH]; static int temp_string_pool_index; @@ -933,22 +61,6 @@ INLINE char *get_temp_string_buffer(void) } -/*------------------------------------------------- - get_safe_classheader - makes sure that the - passed in device is, in fact, a CPU, and - return the class token --------------------------------------------------*/ - -INLINE cpu_class_header *get_safe_classheader(const device_config *device) -{ - assert(device != NULL); - assert(device->classtoken != NULL); - assert(device->class == DEVICE_CLASS_CPU_CHIP); - - return (cpu_class_header *)device->classtoken; -} - - /*************************************************************************** GLOBAL MANAGEMENT @@ -960,88 +72,6 @@ INLINE cpu_class_header *get_safe_classheader(const device_config *device) void cpuintrf_init(running_machine *machine) { - int mapindex; - - /* reset the cpuintrf array */ - memset(cpu_type_header, 0, sizeof(cpu_type_header)); - - /* build the cpuintrf array */ - for (mapindex = 0; mapindex < ARRAY_LENGTH(cpuintrf_map); mapindex++) - { - cpu_type cputype = cpuintrf_map[mapindex].cputype; - cpu_class_header *header = &cpu_type_header[cputype]; - cpuinfo info; - int spacenum; - - /* start with the get_info routine */ - header->cputype = cputype; - header->get_info = cpuintrf_map[mapindex].get_info; - - /* bootstrap the rest of the function pointers */ - info.setinfo = NULL; - (*header->get_info)(NULL, CPUINFO_PTR_SET_INFO, &info); - header->set_info = info.setinfo; - - info.init = NULL; - (*header->get_info)(NULL, CPUINFO_PTR_INIT, &info); - header->init = info.init; - - info.reset = NULL; - (*header->get_info)(NULL, CPUINFO_PTR_RESET, &info); - header->reset = info.reset; - - info.exit = NULL; - (*header->get_info)(NULL, CPUINFO_PTR_EXIT, &info); - header->exit = info.exit; - - info.execute = NULL; - (*header->get_info)(NULL, CPUINFO_PTR_EXECUTE, &info); - header->execute = info.execute; - - info.burn = NULL; - (*header->get_info)(NULL, CPUINFO_PTR_BURN, &info); - header->burn = info.burn; - - info.disassemble = NULL; - (*header->get_info)(NULL, CPUINFO_PTR_DISASSEMBLE, &info); - header->disassemble = info.disassemble; - - info.translate = NULL; - (*header->get_info)(NULL, CPUINFO_PTR_TRANSLATE, &info); - header->translate = info.translate; - - /* get other miscellaneous stuff */ - for (spacenum = 0; spacenum < ARRAY_LENGTH(header->address_shift); spacenum++) - header->address_shift[spacenum] = cputype_get_addrbus_shift(cputype, spacenum); - header->clock_divider = cputype_get_clock_divider(cputype); - header->clock_multiplier = cputype_get_clock_multiplier(cputype); - } - - /* fill in any empty entries with the dummy CPU */ - for (mapindex = 0; mapindex < CPU_COUNT; mapindex++) - if (cpu_type_header[mapindex].get_info == NULL) - cpu_type_header[mapindex] = cpu_type_header[CPU_DUMMY]; -} - - - -/*************************************************************************** - LIVE CONTEXT CONTROL -***************************************************************************/ - -/*------------------------------------------------- - cpu_get_index_slow - find a CPU in the machine - by searching --------------------------------------------------*/ - -int cpu_get_index_slow(const device_config *cpu) -{ - int cpunum; - - for (cpunum = 0; cpunum < ARRAY_LENGTH(Machine->cpu); cpunum++) - if (Machine->cpu[cpunum] == cpu) - return cpunum; - return -1; } @@ -1050,36 +80,6 @@ int cpu_get_index_slow(const device_config *cpu) LIVE CPU ACCESSORS ***************************************************************************/ -/*------------------------------------------------- - cpu_init - initialize a live CPU --------------------------------------------------*/ - -void cpu_init(const device_config *device, int index, int clock, cpu_irq_callback irqcallback) -{ - cpu_class_header *classheader = get_safe_classheader(device); - - classheader->index = index; - classheader->space[ADDRESS_SPACE_PROGRAM] = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM); - classheader->space[ADDRESS_SPACE_DATA] = memory_find_address_space(device, ADDRESS_SPACE_DATA); - classheader->space[ADDRESS_SPACE_IO] = memory_find_address_space(device, ADDRESS_SPACE_IO); - - (*classheader->init)(device, index, clock, irqcallback); -} - - -/*------------------------------------------------- - cpu_exit - free a live CPU --------------------------------------------------*/ - -void cpu_exit(const device_config *device) -{ - cpu_class_header *classheader = get_safe_classheader(device); - - if (classheader->exit != NULL) - (*classheader->exit)(device); -} - - /*------------------------------------------------- cpu_get_info_* - return information about a live CPU @@ -1087,41 +87,41 @@ void cpu_exit(const device_config *device) INT64 cpu_get_info_int(const device_config *device, UINT32 state) { - cpu_class_header *classheader = get_safe_classheader(device); + const cpu_config *config = device->inline_config; cpuinfo info; info.i = 0; - (*classheader->get_info)(device, state, &info); + (*config->type)(device, state, &info); return info.i; } void *cpu_get_info_ptr(const device_config *device, UINT32 state) { - cpu_class_header *classheader = get_safe_classheader(device); + const cpu_config *config = device->inline_config; cpuinfo info; info.p = NULL; - (*classheader->get_info)(device, state, &info); + (*config->type)(device, state, &info); return info.p; } genf *cpu_get_info_fct(const device_config *device, UINT32 state) { - cpu_class_header *classheader = get_safe_classheader(device); + const cpu_config *config = device->inline_config; cpuinfo info; info.f = NULL; - (*classheader->get_info)(device, state, &info); + (*config->type)(device, state, &info); return info.f; } const char *cpu_get_info_string(const device_config *device, UINT32 state) { - cpu_class_header *classheader = get_safe_classheader(device); + const cpu_config *config = device->inline_config; cpuinfo info; info.s = get_temp_string_buffer(); - (*classheader->get_info)(device, state, &info); + (*config->type)(device, state, &info); return info.s; } @@ -1133,7 +133,7 @@ const char *cpu_get_info_string(const device_config *device, UINT32 state) void cpu_set_info_int(const device_config *device, UINT32 state, INT64 data) { - cpu_class_header *classheader = get_safe_classheader(device); + cpu_class_header *classheader = cpu_get_class_header(device); cpuinfo info; info.i = data; @@ -1142,7 +142,7 @@ void cpu_set_info_int(const device_config *device, UINT32 state, INT64 data) void cpu_set_info_ptr(const device_config *device, UINT32 state, void *data) { - cpu_class_header *classheader = get_safe_classheader(device); + cpu_class_header *classheader = cpu_get_class_header(device); cpuinfo info; info.p = data; @@ -1151,7 +151,7 @@ void cpu_set_info_ptr(const device_config *device, UINT32 state, void *data) void cpu_set_info_fct(const device_config *device, UINT32 state, genf *data) { - cpu_class_header *classheader = get_safe_classheader(device); + cpu_class_header *classheader = cpu_get_class_header(device); cpuinfo info; info.f = data; @@ -1160,18 +160,6 @@ void cpu_set_info_fct(const device_config *device, UINT32 state, genf *data) -/*------------------------------------------------- - cpu_reset - signal a reset for a given CPU --------------------------------------------------*/ - -void cpu_reset(const device_config *device) -{ - cpu_class_header *classheader = get_safe_classheader(device); - - (*classheader->reset)(device); -} - - /*------------------------------------------------- cpu_get_physical_pc_byte - return the PC, corrected to a byte offset and translated to @@ -1196,7 +184,7 @@ offs_t cpu_get_physical_pc_byte(const device_config *device) offs_t cpu_dasm(const device_config *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { - cpu_class_header *classheader = get_safe_classheader(device); + cpu_class_header *classheader = cpu_get_class_header(device); offs_t result = 0; /* check for disassembler override */ @@ -1255,7 +243,7 @@ offs_t cpu_dasm(const device_config *device, char *buffer, offs_t pc, const UINT void cpu_set_dasm_override(const device_config *device, cpu_disassemble_func dasm_override) { - cpu_class_header *classheader = get_safe_classheader(device); + cpu_class_header *classheader = cpu_get_class_header(device); classheader->dasm_override = dasm_override; } @@ -1265,18 +253,6 @@ void cpu_set_dasm_override(const device_config *device, cpu_disassemble_func das CPU TYPE ACCESSORS ***************************************************************************/ -/*------------------------------------------------- - cputype_get_header_template - return a header - template for a given CPU type --------------------------------------------------*/ - -const cpu_class_header *cputype_get_header_template(cpu_type cputype) -{ - assert(cputype >= 0 && cputype < CPU_COUNT); - return &cpu_type_header[cputype]; -} - - /*------------------------------------------------- cputype_get_info_* - return information about a given CPU type @@ -1284,45 +260,41 @@ const cpu_class_header *cputype_get_header_template(cpu_type cputype) INT64 cputype_get_info_int(cpu_type cputype, UINT32 state) { - cpu_class_header *classheader = &cpu_type_header[cputype]; cpuinfo info; - assert(cputype >= 0 && cputype < CPU_COUNT); + assert(cputype != NULL); info.i = 0; - (*classheader->get_info)(NULL, state, &info); + (*cputype)(NULL, state, &info); return info.i; } void *cputype_get_info_ptr(cpu_type cputype, UINT32 state) { - cpu_class_header *classheader = &cpu_type_header[cputype]; cpuinfo info; - assert(cputype >= 0 && cputype < CPU_COUNT); + assert(cputype != NULL); info.p = NULL; - (*classheader->get_info)(NULL, state, &info); + (*cputype)(NULL, state, &info); return info.p; } genf *cputype_get_info_fct(cpu_type cputype, UINT32 state) { - cpu_class_header *classheader = &cpu_type_header[cputype]; cpuinfo info; - assert(cputype >= 0 && cputype < CPU_COUNT); + assert(cputype != NULL); info.f = NULL; - (*classheader->get_info)(NULL, state, &info); + (*cputype)(NULL, state, &info); return info.f; } const char *cputype_get_info_string(cpu_type cputype, UINT32 state) { - cpu_class_header *classheader = &cpu_type_header[cputype]; cpuinfo info; - assert(cputype >= 0 && cputype < CPU_COUNT); + assert(cputype != NULL); info.s = get_temp_string_buffer(); - (*classheader->get_info)(NULL, state, &info); + (*cputype)(NULL, state, &info); return info.s; } @@ -1332,14 +304,12 @@ const char *cputype_get_info_string(cpu_type cputype, UINT32 state) DUMMY CPU DEFINITION ***************************************************************************/ -struct dummy_context +typedef struct _dummy_context dummy_context; +struct _dummy_context { - UINT32 dummy; + UINT32 icount; }; -static struct dummy_context dummy_state; -static int dummy_icount; - static CPU_INIT( dummy ) { } static CPU_RESET( dummy ) { } static CPU_EXIT( dummy ) { } @@ -1357,10 +327,11 @@ static CPU_SET_INFO( dummy ) CPU_GET_INFO( dummy ) { + dummy_context *cpustate = (device != NULL) ? device->token : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ - case CPUINFO_INT_CONTEXT_SIZE: info->i = sizeof(dummy_state); break; + case CPUINFO_INT_CONTEXT_SIZE: info->i = sizeof(dummy_context); break; case CPUINFO_INT_INPUT_LINES: info->i = 1; break; case CPUINFO_INT_DEFAULT_IRQ_VECTOR: info->i = 0; break; case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_LITTLE; break; @@ -1395,7 +366,7 @@ CPU_GET_INFO( dummy ) case CPUINFO_PTR_EXECUTE: info->execute = CPU_EXECUTE_NAME(dummy);break; case CPUINFO_PTR_BURN: info->burn = NULL; break; case CPUINFO_PTR_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(dummy); break; - case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &dummy_icount; break; + case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &cpustate->icount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, ""); break; diff --git a/src/emu/cpuintrf.h b/src/emu/cpuintrf.h index 3a8e1059f8b..335d8b65819 100644 --- a/src/emu/cpuintrf.h +++ b/src/emu/cpuintrf.h @@ -20,11 +20,15 @@ #include "state.h" +// mingw has this defined for 32-bit compiles +#undef i386 + + /*************************************************************************** CONSTANTS ***************************************************************************/ -#define MAX_CPU 8 +#define MAX_CPU 8 #define MAX_INPUT_EVENTS 32 @@ -73,11 +77,9 @@ enum /* --- the following bits of info are returned as 64-bit signed integers --- */ CPUINFO_INT_FIRST = DEVINFO_INT_FIRST, - /* direct map to device data */ - CPUINFO_INT_CONTEXT_SIZE = DEVINFO_INT_TOKEN_BYTES, /* R/O: size of CPU context in bytes */ - /* CPU-specific additions */ - CPUINFO_INT_INPUT_LINES = DEVINFO_INT_CLASS_SPECIFIC, /* R/O: number of input lines */ + CPUINFO_INT_CONTEXT_SIZE = DEVINFO_INT_CLASS_SPECIFIC, /* R/O: size of CPU context in bytes */ + CPUINFO_INT_INPUT_LINES, /* R/O: number of input lines */ CPUINFO_INT_OUTPUT_LINES, /* R/O: number of output lines */ CPUINFO_INT_DEFAULT_IRQ_VECTOR, /* R/O: default IRQ vector */ CPUINFO_INT_ENDIANNESS, /* R/O: either ENDIANNESS_BIG or ENDIANNESS_LITTLE */ @@ -126,10 +128,11 @@ enum /* --- the following bits of info are returned as pointers to functions --- */ CPUINFO_FCT_FIRST = DEVINFO_FCT_FIRST, - /* CPU-specific additions */ + /* direct map to device data */ CPUINFO_PTR_RESET = DEVINFO_FCT_RESET, /* R/O: void (*reset)(const device_config *device) */ CPUINFO_PTR_EXIT = DEVINFO_FCT_STOP, /* R/O: void (*exit)(const device_config *device) */ + /* CPU-specific additions */ CPUINFO_PTR_SET_INFO = DEVINFO_FCT_CLASS_SPECIFIC, /* R/O: void (*set_info)(const device_config *device, UINT32 state, INT64 data, void *ptr) */ CPUINFO_PTR_INIT, /* R/O: void (*init)(const device_config *device, int index, int clock, int (*irqcallback)(const device_config *device, int)) */ CPUINFO_PTR_EXECUTE, /* R/O: int (*execute)(const device_config *device, int cycles) */ @@ -207,238 +210,6 @@ enum #define DASMFLAG_STEP_OVER_EXTRA(x) ((x) << DASMFLAG_OVERINSTSHIFT) -/* list of all possible CPUs we might be compiled with */ -enum _cpu_type -{ - CPU_DUMMY, - CPU_Z80, - CPU_Z180, - CPU_8080, - CPU_8085A, - CPU_M6502, - CPU_M65C02, - CPU_M65SC02, - CPU_M65CE02, - CPU_M6509, - CPU_M6510, - CPU_M6510T, - CPU_M7501, - CPU_M8502, - CPU_N2A03, - CPU_DECO16, - CPU_M4510, - CPU_H6280, - CPU_I8086, - CPU_I8088, - CPU_I80186, - CPU_I80188, - CPU_I80286, - CPU_V20, - CPU_V25, - CPU_V30, - CPU_V33, - CPU_V35, - CPU_V60, - CPU_V70, - CPU_I8035, - CPU_I8048, - CPU_I8648, - CPU_I8748, - CPU_MB8884, - CPU_N7751, - CPU_I8039, - CPU_I8049, - CPU_I8749, - CPU_M58715, - CPU_I8041, - CPU_I8741, - CPU_I8042, - CPU_I8242, - CPU_I8742, - CPU_I8031, - CPU_I8032, - CPU_I8051, - CPU_I8052, - CPU_I8751, - CPU_I8752, - CPU_I80C31, - CPU_I80C32, - CPU_I80C51, - CPU_I80C52, - CPU_I87C51, - CPU_I87C52, - CPU_AT89C4051, - CPU_DS5002FP, - CPU_M6800, - CPU_M6801, - CPU_M6802, - CPU_M6803, - CPU_M6808, - CPU_HD63701, - CPU_NSC8105, - CPU_M6805, - CPU_M68705, - CPU_HD63705, - CPU_HD6309, - CPU_M6809, - CPU_M6809E, - CPU_KONAMI, - CPU_M68000, - CPU_M68008, - CPU_M68010, - CPU_M68EC020, - CPU_M68020, - CPU_M68040, - CPU_T11, - CPU_S2650, - CPU_TMS34010, - CPU_TMS34020, - CPU_TI990_10, - CPU_TMS9900, - CPU_TMS9980, - CPU_TMS9995, - CPU_Z8000, - CPU_TMS32010, - CPU_TMS32025, - CPU_TMS32026, - CPU_TMS32031, - CPU_TMS32032, - CPU_TMS32051, - CPU_CCPU, - CPU_ADSP2100, - CPU_ADSP2101, - CPU_ADSP2104, - CPU_ADSP2105, - CPU_ADSP2115, - CPU_ADSP2181, - CPU_PSXCPU, - CPU_ASAP, - CPU_UPD7810, - CPU_UPD7807, - CPU_UPD7801, - CPU_UPD78C05, - CPU_UPD78C06, - CPU_JAGUARGPU, - CPU_JAGUARDSP, - CPU_CQUESTSND, - CPU_CQUESTROT, - CPU_CQUESTLIN, - CPU_R3000BE, - CPU_R3000LE, - CPU_R3041BE, - CPU_R3041LE, - CPU_R4600BE, - CPU_R4600LE, - CPU_R4650BE, - CPU_R4650LE, - CPU_R4700BE, - CPU_R4700LE, - CPU_R5000BE, - CPU_R5000LE, - CPU_QED5271BE, - CPU_QED5271LE, - CPU_RM7000BE, - CPU_RM7000LE, - CPU_ARM, - CPU_ARM7, - CPU_SH1, - CPU_SH2, - CPU_SH4, - CPU_DSP32C, - CPU_PIC16C54, - CPU_PIC16C55, - CPU_PIC16C56, - CPU_PIC16C57, - CPU_PIC16C58, - CPU_G65816, - CPU_SPC700, - CPU_E116T, - CPU_E116XT, - CPU_E116XS, - CPU_E116XSR, - CPU_E132N, - CPU_E132T, - CPU_E132XN, - CPU_E132XT, - CPU_E132XS, - CPU_E132XSR, - CPU_GMS30C2116, - CPU_GMS30C2132, - CPU_GMS30C2216, - CPU_GMS30C2232, - CPU_I386, - CPU_I486, - CPU_PENTIUM, - CPU_MEDIAGX, - CPU_I960, - CPU_H83002, - CPU_H83007, - CPU_H83044, - CPU_H83334, - CPU_V810, - CPU_M37702, - CPU_M37710, - CPU_PPC403GA, - CPU_PPC403GCX, - CPU_PPC601, - CPU_PPC602, - CPU_PPC603, - CPU_PPC603E, - CPU_PPC603R, - CPU_PPC604, - CPU_MPC8240, - CPU_SE3208, - CPU_MC68HC11, - CPU_ADSP21062, - CPU_DSP56156, - CPU_RSP, - CPU_ALPHA8201, - CPU_ALPHA8301, - CPU_CDP1802, - CPU_COP401, - CPU_COP410, - CPU_COP411, - CPU_COP402, - CPU_COP420, - CPU_COP421, - CPU_COP422, - CPU_COP404, - CPU_COP424, - CPU_COP425, - CPU_COP426, - CPU_COP444, - CPU_COP445, - CPU_TMP90840, - CPU_TMP90841, - CPU_TMP91640, - CPU_TMP91641, - CPU_APEXC, - CPU_CP1610, - CPU_F8, - CPU_LH5801, - CPU_PDP1, - CPU_SATURN, - CPU_SC61860, - CPU_TX0_64KW, - CPU_TX0_8KW, - CPU_LR35902, - CPU_TMS7000, - CPU_TMS7000_EXL, - CPU_SM8500, - CPU_V30MZ, - CPU_MB8841, - CPU_MB8842, - CPU_MB8843, - CPU_MB8844, - CPU_MB86233, - CPU_SSP1601, - CPU_MINX, - CPU_CXD8661R, - CPU_COUNT -}; -typedef enum _cpu_type cpu_type; - - /*************************************************************************** MACROS @@ -503,6 +274,10 @@ typedef enum _cpu_type cpu_type; #define CPU_VALIDITY_CHECK_CALL(name) CPU_VALIDITY_CHECK_NAME(name)(driver, config) + +#define cpu_get_index(cpu) device_list_index((cpu)->machine->config->devicelist, CPU, (cpu)->tag) + + /* helpers for accessing common CPU state */ #define cpu_get_context_size(cpu) cpu_get_info_int(cpu, CPUINFO_INT_CONTEXT_SIZE) #define cpu_get_input_lines(cpu) cpu_get_info_int(cpu, CPUINFO_INT_INPUT_LINES) @@ -573,7 +348,7 @@ typedef enum _cpu_type cpu_type; TYPE DEFINITIONS ***************************************************************************/ -/* opaque definition of CPU debugging info */ +/* opaque definition of CPU internal and debugging info */ typedef struct _cpu_debug_data cpu_debug_data; @@ -597,10 +372,13 @@ typedef int (*cpu_write_func)(const device_config *device, int space, UINT32 off typedef int (*cpu_readop_func)(const device_config *device, UINT32 offset, int size, UINT64 *value); typedef void (*cpu_debug_init_func)(const device_config *device); typedef offs_t (*cpu_disassemble_func)(const device_config *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); - typedef int (*cpu_validity_check_func)(const game_driver *driver, const void *config); +/* a cpu_type is just a pointer to the CPU's get_info function */ +typedef cpu_get_info_func cpu_type; + + /* cpuinfo union used to pass data to/from the get_info/set_info functions */ union _cpuinfo { @@ -635,16 +413,11 @@ typedef struct _cpu_class_header cpu_class_header; struct _cpu_class_header { int index; /* index of this CPU */ - cpu_type cputype; /* type index of this CPU */ cpu_debug_data * debug; /* debugging data */ const address_space * space[ADDRESS_SPACES]; /* address spaces */ /* table of core functions */ - cpu_get_info_func get_info; cpu_set_info_func set_info; - cpu_init_func init; - cpu_reset_func reset; - cpu_exit_func exit; cpu_execute_func execute; cpu_burn_func burn; cpu_translate_func translate; @@ -652,13 +425,478 @@ struct _cpu_class_header cpu_disassemble_func dasm_override; /* other frequently-needed information */ - INT8 address_shift[ADDRESS_SPACES]; UINT32 clock_divider; UINT32 clock_multiplier; }; +/*************************************************************************** + CPU DEFINITIONS +***************************************************************************/ + +#define cpu_count(config) device_list_items((config)->devicelist, CPU) +#define cpu_first(config) device_list_first((config)->devicelist, CPU) +#define cpu_next(previous) device_list_next((previous), CPU) + + +/* signal a reset for a given CPU */ +#define cpu_reset device_reset + + + +/* eventually all drivers should include the CPU core's header, which should define these */ +CPU_GET_INFO( dummy ); +#define CPU_DUMMY CPU_GET_INFO_NAME( dummy ) +CPU_GET_INFO( z80 ); +#define CPU_Z80 CPU_GET_INFO_NAME( z80 ) +CPU_GET_INFO( z180 ); +#define CPU_Z180 CPU_GET_INFO_NAME( z180 ) +CPU_GET_INFO( i8080 ); +#define CPU_8080 CPU_GET_INFO_NAME( i8080 ) +CPU_GET_INFO( i8085 ); +#define CPU_8085A CPU_GET_INFO_NAME( i8085 ) +CPU_GET_INFO( m6502 ); +#define CPU_M6502 CPU_GET_INFO_NAME( m6502 ) +CPU_GET_INFO( m65c02 ); +#define CPU_M65C02 CPU_GET_INFO_NAME( m65c02 ) +CPU_GET_INFO( m65sc02 ); +#define CPU_M65SC02 CPU_GET_INFO_NAME( m65sc02 ) +CPU_GET_INFO( m65ce02 ); +#define CPU_M65CE02 CPU_GET_INFO_NAME( m65ce02 ) +CPU_GET_INFO( m6509 ); +#define CPU_M6509 CPU_GET_INFO_NAME( m6509 ) +CPU_GET_INFO( m6510 ); +#define CPU_M6510 CPU_GET_INFO_NAME( m6510 ) +CPU_GET_INFO( m6510t ); +#define CPU_M6510T CPU_GET_INFO_NAME( m6510t ) +CPU_GET_INFO( m7501 ); +#define CPU_M7501 CPU_GET_INFO_NAME( m7501 ) +CPU_GET_INFO( m8502 ); +#define CPU_M8502 CPU_GET_INFO_NAME( m8502 ) +CPU_GET_INFO( n2a03 ); +#define CPU_N2A03 CPU_GET_INFO_NAME( n2a03 ) +CPU_GET_INFO( deco16 ); +#define CPU_DECO16 CPU_GET_INFO_NAME( deco16 ) +CPU_GET_INFO( m4510 ); +#define CPU_M4510 CPU_GET_INFO_NAME( m4510 ) +CPU_GET_INFO( h6280 ); +#define CPU_H6280 CPU_GET_INFO_NAME( h6280 ) +CPU_GET_INFO( i8086 ); +#define CPU_I8086 CPU_GET_INFO_NAME( i8086 ) +CPU_GET_INFO( i8088 ); +#define CPU_I8088 CPU_GET_INFO_NAME( i8088 ) +CPU_GET_INFO( i80186 ); +#define CPU_I80186 CPU_GET_INFO_NAME( i80186 ) +CPU_GET_INFO( i80188 ); +#define CPU_I80188 CPU_GET_INFO_NAME( i80188 ) +CPU_GET_INFO( i80286 ); +#define CPU_I80286 CPU_GET_INFO_NAME( i80286 ) +CPU_GET_INFO( v20 ); +#define CPU_V20 CPU_GET_INFO_NAME( v20 ) +CPU_GET_INFO( v25 ); +#define CPU_V25 CPU_GET_INFO_NAME( v25 ) +CPU_GET_INFO( v30 ); +#define CPU_V30 CPU_GET_INFO_NAME( v30 ) +CPU_GET_INFO( v33 ); +#define CPU_V33 CPU_GET_INFO_NAME( v33 ) +CPU_GET_INFO( v35 ); +#define CPU_V35 CPU_GET_INFO_NAME( v35 ) +CPU_GET_INFO( v60 ); +#define CPU_V60 CPU_GET_INFO_NAME( v60 ) +CPU_GET_INFO( v70 ); +#define CPU_V70 CPU_GET_INFO_NAME( v70 ) +CPU_GET_INFO( i8035 ); +#define CPU_I8035 CPU_GET_INFO_NAME( i8035 ) +CPU_GET_INFO( i8048 ); +#define CPU_I8048 CPU_GET_INFO_NAME( i8048 ) +CPU_GET_INFO( i8648 ); +#define CPU_I8648 CPU_GET_INFO_NAME( i8648 ) +CPU_GET_INFO( i8748 ); +#define CPU_I8748 CPU_GET_INFO_NAME( i8748 ) +CPU_GET_INFO( mb8884 ); +#define CPU_MB8884 CPU_GET_INFO_NAME( mb8884 ) +CPU_GET_INFO( n7751 ); +#define CPU_N7751 CPU_GET_INFO_NAME( n7751 ) +CPU_GET_INFO( i8039 ); +#define CPU_I8039 CPU_GET_INFO_NAME( i8039 ) +CPU_GET_INFO( i8049 ); +#define CPU_I8049 CPU_GET_INFO_NAME( i8049 ) +CPU_GET_INFO( i8749 ); +#define CPU_I8749 CPU_GET_INFO_NAME( i8749 ) +CPU_GET_INFO( m58715 ); +#define CPU_M58715 CPU_GET_INFO_NAME( m58715 ) +CPU_GET_INFO( i8041 ); +#define CPU_I8041 CPU_GET_INFO_NAME( i8041 ) +CPU_GET_INFO( i8741 ); +#define CPU_I8741 CPU_GET_INFO_NAME( i8741 ) +CPU_GET_INFO( i8042 ); +#define CPU_I8042 CPU_GET_INFO_NAME( i8042 ) +CPU_GET_INFO( i8242 ); +#define CPU_I8242 CPU_GET_INFO_NAME( i8242 ) +CPU_GET_INFO( i8742 ); +#define CPU_I8742 CPU_GET_INFO_NAME( i8742 ) +CPU_GET_INFO( i8031 ); +#define CPU_I8031 CPU_GET_INFO_NAME( i8031 ) +CPU_GET_INFO( i8032 ); +#define CPU_I8032 CPU_GET_INFO_NAME( i8032 ) +CPU_GET_INFO( i8051 ); +#define CPU_I8051 CPU_GET_INFO_NAME( i8051 ) +CPU_GET_INFO( i8052 ); +#define CPU_I8052 CPU_GET_INFO_NAME( i8052 ) +CPU_GET_INFO( i8751 ); +#define CPU_I8751 CPU_GET_INFO_NAME( i8751 ) +CPU_GET_INFO( i8752 ); +#define CPU_I8752 CPU_GET_INFO_NAME( i8752 ) +CPU_GET_INFO( i80c31 ); +#define CPU_I80C31 CPU_GET_INFO_NAME( i80c31 ) +CPU_GET_INFO( i80c32 ); +#define CPU_I80C32 CPU_GET_INFO_NAME( i80c32 ) +CPU_GET_INFO( i80c51 ); +#define CPU_I80C51 CPU_GET_INFO_NAME( i80c51 ) +CPU_GET_INFO( i80c52 ); +#define CPU_I80C52 CPU_GET_INFO_NAME( i80c52 ) +CPU_GET_INFO( i87c51 ); +#define CPU_I87C51 CPU_GET_INFO_NAME( i87c51 ) +CPU_GET_INFO( i87c52 ); +#define CPU_I87C52 CPU_GET_INFO_NAME( i87c52 ) +CPU_GET_INFO( at89c4051 ); +#define CPU_AT89C4051 CPU_GET_INFO_NAME( at89c4051 ) +CPU_GET_INFO( ds5002fp ); +#define CPU_DS5002FP CPU_GET_INFO_NAME( ds5002fp ) +CPU_GET_INFO( m6800 ); +#define CPU_M6800 CPU_GET_INFO_NAME( m6800 ) +CPU_GET_INFO( m6801 ); +#define CPU_M6801 CPU_GET_INFO_NAME( m6801 ) +CPU_GET_INFO( m6802 ); +#define CPU_M6802 CPU_GET_INFO_NAME( m6802 ) +CPU_GET_INFO( m6803 ); +#define CPU_M6803 CPU_GET_INFO_NAME( m6803 ) +CPU_GET_INFO( m6808 ); +#define CPU_M6808 CPU_GET_INFO_NAME( m6808 ) +CPU_GET_INFO( hd63701 ); +#define CPU_HD63701 CPU_GET_INFO_NAME( hd63701 ) +CPU_GET_INFO( nsc8105 ); +#define CPU_NSC8105 CPU_GET_INFO_NAME( nsc8105 ) +CPU_GET_INFO( m6805 ); +#define CPU_M6805 CPU_GET_INFO_NAME( m6805 ) +CPU_GET_INFO( m68705 ); +#define CPU_M68705 CPU_GET_INFO_NAME( m68705 ) +CPU_GET_INFO( hd63705 ); +#define CPU_HD63705 CPU_GET_INFO_NAME( hd63705 ) +CPU_GET_INFO( hd6309 ); +#define CPU_HD6309 CPU_GET_INFO_NAME( hd6309 ) +CPU_GET_INFO( m6809 ); +#define CPU_M6809 CPU_GET_INFO_NAME( m6809 ) +CPU_GET_INFO( m6809e ); +#define CPU_M6809E CPU_GET_INFO_NAME( m6809e ) +CPU_GET_INFO( konami ); +#define CPU_KONAMI CPU_GET_INFO_NAME( konami ) +CPU_GET_INFO( m68000 ); +#define CPU_M68000 CPU_GET_INFO_NAME( m68000 ) +CPU_GET_INFO( m68008 ); +#define CPU_M68008 CPU_GET_INFO_NAME( m68008 ) +CPU_GET_INFO( m68010 ); +#define CPU_M68010 CPU_GET_INFO_NAME( m68010 ) +CPU_GET_INFO( m68ec020 ); +#define CPU_M68EC020 CPU_GET_INFO_NAME( m68ec020 ) +CPU_GET_INFO( m68020 ); +#define CPU_M68020 CPU_GET_INFO_NAME( m68020 ) +CPU_GET_INFO( m68040 ); +#define CPU_M68040 CPU_GET_INFO_NAME( m68040 ) +CPU_GET_INFO( t11 ); +#define CPU_T11 CPU_GET_INFO_NAME( t11 ) +CPU_GET_INFO( s2650 ); +#define CPU_S2650 CPU_GET_INFO_NAME( s2650 ) +CPU_GET_INFO( tms34010 ); +#define CPU_TMS34010 CPU_GET_INFO_NAME( tms34010 ) +CPU_GET_INFO( tms34020 ); +#define CPU_TMS34020 CPU_GET_INFO_NAME( tms34020 ) +CPU_GET_INFO( ti990_10 ); +#define CPU_TI990_10 CPU_GET_INFO_NAME( ti990_10 ) +CPU_GET_INFO( tms9900 ); +#define CPU_TMS9900 CPU_GET_INFO_NAME( tms9900 ) +CPU_GET_INFO( tms9980a ); +#define CPU_TMS9980 CPU_GET_INFO_NAME( tms9980a ) +CPU_GET_INFO( tms9995 ); +#define CPU_TMS9995 CPU_GET_INFO_NAME( tms9995 ) +CPU_GET_INFO( z8000 ); +#define CPU_Z8000 CPU_GET_INFO_NAME( z8000 ) +CPU_GET_INFO( tms32010 ); +#define CPU_TMS32010 CPU_GET_INFO_NAME( tms32010 ) +CPU_GET_INFO( tms32025 ); +#define CPU_TMS32025 CPU_GET_INFO_NAME( tms32025 ) +CPU_GET_INFO( tms32026 ); +#define CPU_TMS32026 CPU_GET_INFO_NAME( tms32026 ) +CPU_GET_INFO( tms32031 ); +#define CPU_TMS32031 CPU_GET_INFO_NAME( tms32031 ) +CPU_GET_INFO( tms32032 ); +#define CPU_TMS32032 CPU_GET_INFO_NAME( tms32032 ) +CPU_GET_INFO( tms32051 ); +#define CPU_TMS32051 CPU_GET_INFO_NAME( tms32051 ) +CPU_GET_INFO( ccpu ); +#define CPU_CCPU CPU_GET_INFO_NAME( ccpu ) +CPU_GET_INFO( adsp2100 ); +#define CPU_ADSP2100 CPU_GET_INFO_NAME( adsp2100 ) + CPU_GET_INFO( adsp2101 ); +#define CPU_ADSP2101 CPU_GET_INFO_NAME( adsp2101 ) +CPU_GET_INFO( adsp2104 ); +#define CPU_ADSP2104 CPU_GET_INFO_NAME( adsp2104 ) +CPU_GET_INFO( adsp2105 ); +#define CPU_ADSP2105 CPU_GET_INFO_NAME( adsp2105 ) +CPU_GET_INFO( adsp2115 ); +#define CPU_ADSP2115 CPU_GET_INFO_NAME( adsp2115 ) +CPU_GET_INFO( adsp2181 ); +#define CPU_ADSP2181 CPU_GET_INFO_NAME( adsp2181 ) +CPU_GET_INFO( psxcpu ); +#define CPU_PSXCPU CPU_GET_INFO_NAME( psxcpu ) +CPU_GET_INFO( asap ); +#define CPU_ASAP CPU_GET_INFO_NAME( asap ) +CPU_GET_INFO( upd7810 ); +#define CPU_UPD7810 CPU_GET_INFO_NAME( upd7810 ) +CPU_GET_INFO( upd7807 ); +#define CPU_UPD7807 CPU_GET_INFO_NAME( upd7807 ) +CPU_GET_INFO( upd7801 ); +#define CPU_UPD7801 CPU_GET_INFO_NAME( upd7801 ) +CPU_GET_INFO( upd78C05 ); +#define CPU_UPD78C05 CPU_GET_INFO_NAME( upd78C05 ) +CPU_GET_INFO( upd78C06 ); +#define CPU_UPD78C06 CPU_GET_INFO_NAME( upd78C06 ) +CPU_GET_INFO( jaguargpu ); +#define CPU_JAGUARGPU CPU_GET_INFO_NAME( jaguargpu ) +CPU_GET_INFO( jaguardsp ); +#define CPU_JAGUARDSP CPU_GET_INFO_NAME( jaguardsp ) +CPU_GET_INFO( cquestsnd ); +#define CPU_CQUESTSND CPU_GET_INFO_NAME( cquestsnd ) +CPU_GET_INFO( cquestrot ); +#define CPU_CQUESTROT CPU_GET_INFO_NAME( cquestrot ) +CPU_GET_INFO( cquestlin ); +#define CPU_CQUESTLIN CPU_GET_INFO_NAME( cquestlin ) +CPU_GET_INFO( r3000be ); +#define CPU_R3000BE CPU_GET_INFO_NAME( r3000be ) +CPU_GET_INFO( r3000le ); +#define CPU_R3000LE CPU_GET_INFO_NAME( r3000le ) +CPU_GET_INFO( r3041be ); +#define CPU_R3041BE CPU_GET_INFO_NAME( r3041be ) +CPU_GET_INFO( r3041le ); +#define CPU_R3041LE CPU_GET_INFO_NAME( r3041le ) +CPU_GET_INFO( r4600be ); +#define CPU_R4600BE CPU_GET_INFO_NAME( r4600be ) +CPU_GET_INFO( r4600le ); +#define CPU_R4600LE CPU_GET_INFO_NAME( r4600le ) +CPU_GET_INFO( r4650be ); +#define CPU_R4650BE CPU_GET_INFO_NAME( r4650be ) +CPU_GET_INFO( r4650le ); +#define CPU_R4650LE CPU_GET_INFO_NAME( r4650le ) +CPU_GET_INFO( r4700be ); +#define CPU_R4700BE CPU_GET_INFO_NAME( r4700be ) +CPU_GET_INFO( r4700le ); +#define CPU_R4700LE CPU_GET_INFO_NAME( r4700le ) +CPU_GET_INFO( r5000be ); +#define CPU_R5000BE CPU_GET_INFO_NAME( r5000be ) +CPU_GET_INFO( r5000le ); +#define CPU_R5000LE CPU_GET_INFO_NAME( r5000le ) +CPU_GET_INFO( qed5271be ); +#define CPU_QED5271BE CPU_GET_INFO_NAME( qed5271be ) +CPU_GET_INFO( qed5271le ); +#define CPU_QED5271LE CPU_GET_INFO_NAME( qed5271le ) +CPU_GET_INFO( rm7000be ); +#define CPU_RM7000BE CPU_GET_INFO_NAME( rm7000be ) +CPU_GET_INFO( rm7000le ); +#define CPU_RM7000LE CPU_GET_INFO_NAME( rm7000le ) +CPU_GET_INFO( arm ); +#define CPU_ARM CPU_GET_INFO_NAME( arm ) +CPU_GET_INFO( arm7 ); +#define CPU_ARM7 CPU_GET_INFO_NAME( arm7 ) +CPU_GET_INFO( sh1 ); +#define CPU_SH1 CPU_GET_INFO_NAME( sh1 ) +CPU_GET_INFO( sh2 ); +#define CPU_SH2 CPU_GET_INFO_NAME( sh2 ) +CPU_GET_INFO( sh4 ); +#define CPU_SH4 CPU_GET_INFO_NAME( sh4 ) +CPU_GET_INFO( dsp32c ); +#define CPU_DSP32C CPU_GET_INFO_NAME( dsp32c ) +CPU_GET_INFO( pic16c54 ); +#define CPU_PIC16C54 CPU_GET_INFO_NAME( pic16c54 ) +CPU_GET_INFO( pic16c55 ); +#define CPU_PIC16C55 CPU_GET_INFO_NAME( pic16c55 ) +CPU_GET_INFO( pic16c56 ); +#define CPU_PIC16C56 CPU_GET_INFO_NAME( pic16c56 ) +CPU_GET_INFO( pic16c57 ); +#define CPU_PIC16C57 CPU_GET_INFO_NAME( pic16c57 ) +CPU_GET_INFO( pic16c58 ); +#define CPU_PIC16C58 CPU_GET_INFO_NAME( pic16c58 ) +CPU_GET_INFO( g65816 ); +#define CPU_G65816 CPU_GET_INFO_NAME( g65816 ) +CPU_GET_INFO( spc700 ); +#define CPU_SPC700 CPU_GET_INFO_NAME( spc700 ) +CPU_GET_INFO( e116t ); +#define CPU_E116T CPU_GET_INFO_NAME( e116t ) +CPU_GET_INFO( e116xt ); +#define CPU_E116XT CPU_GET_INFO_NAME( e116xt ) +CPU_GET_INFO( e116xs ); +#define CPU_E116XS CPU_GET_INFO_NAME( e116xs ) +CPU_GET_INFO( e116xsr ); +#define CPU_E116XSR CPU_GET_INFO_NAME( e116xsr ) +CPU_GET_INFO( e132n ); +#define CPU_E132N CPU_GET_INFO_NAME( e132n ) +CPU_GET_INFO( e132t ); +#define CPU_E132T CPU_GET_INFO_NAME( e132t ) +CPU_GET_INFO( e132xn ); +#define CPU_E132XN CPU_GET_INFO_NAME( e132xn ) +CPU_GET_INFO( e132xt ); +#define CPU_E132XT CPU_GET_INFO_NAME( e132xt ) +CPU_GET_INFO( e132xs ); +#define CPU_E132XS CPU_GET_INFO_NAME( e132xs ) +CPU_GET_INFO( e132xsr ); +#define CPU_E132XSR CPU_GET_INFO_NAME( e132xsr ) +CPU_GET_INFO( gms30c2116 ); +#define CPU_GMS30C2116 CPU_GET_INFO_NAME( gms30c2116 ) +CPU_GET_INFO( gms30c2132 ); +#define CPU_GMS30C2132 CPU_GET_INFO_NAME( gms30c2132 ) +CPU_GET_INFO( gms30c2216 ); +#define CPU_GMS30C2216 CPU_GET_INFO_NAME( gms30c2216 ) +CPU_GET_INFO( gms30c2232 ); +#define CPU_GMS30C2232 CPU_GET_INFO_NAME( gms30c2232 ) +CPU_GET_INFO( i386 ); +#define CPU_I386 CPU_GET_INFO_NAME( i386 ) +CPU_GET_INFO( i486 ); +#define CPU_I486 CPU_GET_INFO_NAME( i486 ) +CPU_GET_INFO( pentium ); +#define CPU_PENTIUM CPU_GET_INFO_NAME( pentium ) +CPU_GET_INFO( mediagx ); +#define CPU_MEDIAGX CPU_GET_INFO_NAME( mediagx ) +CPU_GET_INFO( i960 ); +#define CPU_I960 CPU_GET_INFO_NAME( i960 ) +CPU_GET_INFO( h8_3002 ); +#define CPU_H83002 CPU_GET_INFO_NAME( h8_3002 ) +CPU_GET_INFO( h8_3007 ); +#define CPU_H83007 CPU_GET_INFO_NAME( h8_3007 ) +CPU_GET_INFO( h8_3044 ); +#define CPU_H83044 CPU_GET_INFO_NAME( h8_3044 ) +CPU_GET_INFO( h8_3334 ); +#define CPU_H83334 CPU_GET_INFO_NAME( h8_3334 ) +CPU_GET_INFO( v810 ); +#define CPU_V810 CPU_GET_INFO_NAME( v810 ) +CPU_GET_INFO( m37702 ); +#define CPU_M37702 CPU_GET_INFO_NAME( m37702 ) +CPU_GET_INFO( m37710 ); +#define CPU_M37710 CPU_GET_INFO_NAME( m37710 ) +CPU_GET_INFO( ppc403ga ); +#define CPU_PPC403GA CPU_GET_INFO_NAME( ppc403ga ) +CPU_GET_INFO( ppc403gcx ); +#define CPU_PPC403GCX CPU_GET_INFO_NAME( ppc403gcx ) +CPU_GET_INFO( ppc601 ); +#define CPU_PPC601 CPU_GET_INFO_NAME( ppc601 ) +CPU_GET_INFO( ppc602 ); +#define CPU_PPC602 CPU_GET_INFO_NAME( ppc602 ) +CPU_GET_INFO( ppc603 ); +#define CPU_PPC603 CPU_GET_INFO_NAME( ppc603 ) +CPU_GET_INFO( ppc603e ); +#define CPU_PPC603E CPU_GET_INFO_NAME( ppc603e ) +CPU_GET_INFO( ppc603r ); +#define CPU_PPC603R CPU_GET_INFO_NAME( ppc603r ) +CPU_GET_INFO( ppc604 ); +#define CPU_PPC604 CPU_GET_INFO_NAME( ppc604 ) +CPU_GET_INFO( mpc8240 ); +#define CPU_MPC8240 CPU_GET_INFO_NAME( mpc8240 ) +CPU_GET_INFO( se3208 ); +#define CPU_SE3208 CPU_GET_INFO_NAME( se3208 ) +CPU_GET_INFO( mc68hc11 ); +#define CPU_MC68HC11 CPU_GET_INFO_NAME( mc68hc11 ) +CPU_GET_INFO( adsp21062 ); +#define CPU_ADSP21062 CPU_GET_INFO_NAME( adsp21062 ) +CPU_GET_INFO( dsp56k ); +#define CPU_DSP56156 CPU_GET_INFO_NAME( dsp56k ) +CPU_GET_INFO( rsp ); +#define CPU_RSP CPU_GET_INFO_NAME( rsp ) +CPU_GET_INFO( alpha8201 ); +#define CPU_ALPHA8201 CPU_GET_INFO_NAME( alpha8201 ) +CPU_GET_INFO( alpha8301 ); +#define CPU_ALPHA8301 CPU_GET_INFO_NAME( alpha8301 ) +CPU_GET_INFO( cdp1802 ); +#define CPU_CDP1802 CPU_GET_INFO_NAME( cdp1802 ) +CPU_GET_INFO( cop401 ); +#define CPU_COP401 CPU_GET_INFO_NAME( cop401 ) +CPU_GET_INFO( cop410 ); +#define CPU_COP410 CPU_GET_INFO_NAME( cop410 ) +CPU_GET_INFO( cop411 ); +#define CPU_COP411 CPU_GET_INFO_NAME( cop411 ) +CPU_GET_INFO( cop402 ); +#define CPU_COP402 CPU_GET_INFO_NAME( cop402 ) +CPU_GET_INFO( cop420 ); +#define CPU_COP420 CPU_GET_INFO_NAME( cop420 ) +CPU_GET_INFO( cop421 ); +#define CPU_COP421 CPU_GET_INFO_NAME( cop421 ) +CPU_GET_INFO( cop422 ); +#define CPU_COP422 CPU_GET_INFO_NAME( cop422 ) +CPU_GET_INFO( cop404 ); +#define CPU_COP404 CPU_GET_INFO_NAME( cop404 ) +CPU_GET_INFO( cop424 ); +#define CPU_COP424 CPU_GET_INFO_NAME( cop424 ) +CPU_GET_INFO( cop425 ); +#define CPU_COP425 CPU_GET_INFO_NAME( cop425 ) +CPU_GET_INFO( cop426 ); +#define CPU_COP426 CPU_GET_INFO_NAME( cop426 ) +CPU_GET_INFO( cop444 ); +#define CPU_COP444 CPU_GET_INFO_NAME( cop444 ) +CPU_GET_INFO( cop445 ); +#define CPU_COP445 CPU_GET_INFO_NAME( cop445 ) +CPU_GET_INFO( tmp90840 ); +#define CPU_TMP90840 CPU_GET_INFO_NAME( tmp90840 ) +CPU_GET_INFO( tmp90841 ); +#define CPU_TMP90841 CPU_GET_INFO_NAME( tmp90841 ) +CPU_GET_INFO( tmp91640 ); +#define CPU_TMP91640 CPU_GET_INFO_NAME( tmp91640 ) +CPU_GET_INFO( tmp91641 ); +#define CPU_TMP91641 CPU_GET_INFO_NAME( tmp91641 ) +CPU_GET_INFO( apexc ); +#define CPU_APEXC CPU_GET_INFO_NAME( apexc ) +CPU_GET_INFO( cp1610 ); +#define CPU_CP1610 CPU_GET_INFO_NAME( cp1610 ) +CPU_GET_INFO( f8 ); +#define CPU_F8 CPU_GET_INFO_NAME( f8 ) +CPU_GET_INFO( lh5801 ); +#define CPU_LH5801 CPU_GET_INFO_NAME( lh5801 ) +CPU_GET_INFO( pdp1 ); +#define CPU_PDP1 CPU_GET_INFO_NAME( pdp1 ) +CPU_GET_INFO( saturn ); +#define CPU_SATURN CPU_GET_INFO_NAME( saturn ) +CPU_GET_INFO( sc61860 ); +#define CPU_SC61860 CPU_GET_INFO_NAME( sc61860 ) +CPU_GET_INFO( tx0_64kw ); +#define CPU_TX0_64KW CPU_GET_INFO_NAME( tx0_64kw ) +CPU_GET_INFO( tx0_8kw ); +#define CPU_TX0_8KW CPU_GET_INFO_NAME( tx0_8kw ) +CPU_GET_INFO( lrR35902 ); +#define CPU_LR35902 CPU_GET_INFO_NAME( lr35902 ) +CPU_GET_INFO( tms7000 ); +#define CPU_TMS7000 CPU_GET_INFO_NAME( tms7000 ) +CPU_GET_INFO( tms7000_EXL ); +#define CPU_TMS7000_EXL CPU_GET_INFO_NAME( tms7000_EXL ) +CPU_GET_INFO( SM8500 ); +#define CPU_sm8500 CPU_GET_INFO_NAME( sm8500 ) +CPU_GET_INFO( v30mz ); +#define CPU_V30MZ CPU_GET_INFO_NAME( v30mz ) +CPU_GET_INFO( mb8841 ); +#define CPU_MB8841 CPU_GET_INFO_NAME( mb8841 ) +CPU_GET_INFO( mb8842 ); +#define CPU_MB8842 CPU_GET_INFO_NAME( mb8842 ) +CPU_GET_INFO( mb8843 ); +#define CPU_MB8843 CPU_GET_INFO_NAME( mb8843 ) +CPU_GET_INFO( mb8844 ); +#define CPU_MB8844 CPU_GET_INFO_NAME( mb8844 ) +CPU_GET_INFO( mb86233 ); +#define CPU_MB86233 CPU_GET_INFO_NAME( mb86233 ) +CPU_GET_INFO( ssp1601 ); +#define CPU_SSP1601 CPU_GET_INFO_NAME( ssp1601 ) +CPU_GET_INFO( minx ); +#define CPU_MINX CPU_GET_INFO_NAME( minx ) +CPU_GET_INFO( cxd8661r ); +#define CPU_CXD8661R CPU_GET_INFO_NAME( cxd8661r ) + + + /*************************************************************************** FUNCTION PROTOTYPES ***************************************************************************/ @@ -674,21 +912,8 @@ char *cpuintrf_temp_str(void); -/* ----- live context control ----- */ - -/* find a CPU in the machine by searching */ -int cpu_get_index_slow(const device_config *cpu); - - - /* ----- live CPU accessors ----- */ -/* initialize a live CPU */ -void cpu_init(const device_config *cpu, int index, int clock, cpu_irq_callback irqcallback); - -/* free a live CPU */ -void cpu_exit(const device_config *cpu); - /* return information about a live CPU */ INT64 cpu_get_info_int(const device_config *cpu, UINT32 state); void *cpu_get_info_ptr(const device_config *cpu, UINT32 state); @@ -700,9 +925,6 @@ void cpu_set_info_int(const device_config *cpu, UINT32 state, INT64 data); void cpu_set_info_ptr(const device_config *cpu, UINT32 state, void *data); void cpu_set_info_fct(const device_config *cpu, UINT32 state, genf *data); -/* signal a reset for a given CPU */ -void cpu_reset(const device_config *cpu); - /* return the PC, corrected to a byte offset and translated to physical space, on a given CPU */ offs_t cpu_get_physical_pc_byte(const device_config *cpu); @@ -716,9 +938,6 @@ void cpu_set_dasm_override(const device_config *cpu, cpu_disassemble_func dasm_o /* ----- CPU type accessors ----- */ -/* return a header template for a given CPU type */ -const cpu_class_header *cputype_get_header_template(cpu_type cputype); - /* return information about a given CPU type */ INT64 cputype_get_info_int(cpu_type cputype, UINT32 state); void *cputype_get_info_ptr(cpu_type cputype, UINT32 state); @@ -732,14 +951,15 @@ const char *cputype_get_info_string(cpu_type cputype, UINT32 state); ***************************************************************************/ /*------------------------------------------------- - cpu_get_index - return the index of the - specified CPU (deprecated soon) + cpu_get_class_header - return a pointer to + the class header -------------------------------------------------*/ -INLINE int cpu_get_index(const device_config *cpu) +INLINE cpu_class_header *cpu_get_class_header(const device_config *device) { - cpu_class_header *classheader = cpu->classtoken; - return (classheader != NULL) ? classheader->index : cpu_get_index_slow(cpu); + if (device->token != NULL) + return (cpu_class_header *)((UINT8 *)device->token + device->tokenbytes) - 1; + return NULL; } @@ -748,9 +968,9 @@ INLINE int cpu_get_index(const device_config *cpu) the given CPU's debugger data -------------------------------------------------*/ -INLINE cpu_debug_data *cpu_get_debug_data(const device_config *cpu) +INLINE cpu_debug_data *cpu_get_debug_data(const device_config *device) { - cpu_class_header *classheader = cpu->classtoken; + cpu_class_header *classheader = cpu_get_class_header(device); return classheader->debug; } @@ -760,10 +980,15 @@ INLINE cpu_debug_data *cpu_get_debug_data(const device_config *cpu) the given CPU's address space -------------------------------------------------*/ -INLINE const address_space *cpu_get_address_space(const device_config *cpu, int spacenum) +INLINE const address_space *cpu_get_address_space(const device_config *device, int spacenum) { - cpu_class_header *classheader = cpu->classtoken; - return classheader->space[spacenum]; + /* it is faster to pull this from the class header, but only after we've started */ + if (device->token != NULL) + { + cpu_class_header *classheader = cpu_get_class_header(device); + return classheader->space[spacenum]; + } + return memory_find_address_space(device, spacenum); } @@ -774,7 +999,7 @@ INLINE const address_space *cpu_get_address_space(const device_config *cpu, int INLINE int cpu_execute(const device_config *device, int cycles) { - cpu_class_header *classheader = device->classtoken; + cpu_class_header *classheader = cpu_get_class_header(device); return (*classheader->execute)(device, cycles); } diff --git a/src/emu/debug/debugcmd.c b/src/emu/debug/debugcmd.c index e267e745406..b96b52d152f 100644 --- a/src/emu/debug/debugcmd.c +++ b/src/emu/debug/debugcmd.c @@ -124,8 +124,9 @@ static void execute_hardreset(running_machine *machine, int ref, int params, con void debug_command_init(running_machine *machine) { symbol_table *symtable = debug_cpu_get_global_symtable(machine); - int cpunum, itemnum; + const device_config *cpu; const char *name; + int itemnum; /* add a few simple global functions */ symtable_add_function(symtable, "min", NULL, 2, 2, execute_min); @@ -244,14 +245,13 @@ void debug_command_init(running_machine *machine) debug_console_register_command(machine, "hardreset", CMDFLAG_NONE, 0, 0, 1, execute_hardreset); /* ask all the CPUs if they would like to register functions or symbols */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) - { - cpu_debug_init_func debug_init; - debug_init = (cpu_debug_init_func)cpu_get_info_fct(machine->cpu[cpunum], CPUINFO_PTR_DEBUG_INIT); - if (debug_init != NULL) - (*debug_init)(machine->cpu[cpunum]); - } + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + { + cpu_debug_init_func debug_init; + debug_init = (cpu_debug_init_func)cpu_get_info_fct(cpu, CPUINFO_PTR_DEBUG_INIT); + if (debug_init != NULL) + (*debug_init)(cpu); + } add_exit_callback(machine, debug_command_exit); @@ -268,12 +268,11 @@ void debug_command_init(running_machine *machine) static void debug_command_exit(running_machine *machine) { - int cpunum; + const device_config *cpu; /* turn off all traces */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) - debug_cpu_trace(machine->cpu[cpunum], NULL, 0, NULL); + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + debug_cpu_trace(cpu, NULL, 0, NULL); } @@ -854,8 +853,8 @@ static void execute_next(running_machine *machine, int ref, int params, const ch static void execute_focus(running_machine *machine, int ref, int params, const char *param[]) { + const device_config *scancpu; const device_config *cpu; - int cpunum; /* validate params */ if (!debug_command_parameter_cpu(machine, param[0], &cpu)) @@ -865,9 +864,9 @@ static void execute_focus(running_machine *machine, int ref, int params, const c debug_cpu_ignore_cpu(cpu, 0); /* then loop over CPUs and set the ignore flags on all other CPUs */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL && machine->cpu[cpunum] != cpu) - debug_cpu_ignore_cpu(machine->cpu[cpunum], 1); + for (scancpu = machine->cpu[0]; scancpu != NULL; scancpu = scancpu->typenext) + if (scancpu != cpu) + debug_cpu_ignore_cpu(scancpu, 1); debug_console_printf(machine, "Now focused on CPU '%s'\n", cpu->tag); } @@ -879,7 +878,8 @@ static void execute_focus(running_machine *machine, int ref, int params, const c static void execute_ignore(running_machine *machine, int ref, int params, const char *param[]) { const device_config *cpuwhich[MAX_COMMAND_PARAMS]; - int cpunum, paramnum; + const device_config *cpu; + int paramnum; char buffer[100]; int buflen = 0; @@ -887,20 +887,19 @@ static void execute_ignore(running_machine *machine, int ref, int params, const if (params == 0) { /* loop over all CPUs */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) - { - const cpu_debug_data *cpuinfo = cpu_get_debug_data(machine->cpu[cpunum]); + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + { + const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); - /* build up a comma-separated list */ - if ((cpuinfo->flags & DEBUG_FLAG_OBSERVING) == 0) - { - if (buflen == 0) - buflen += sprintf(&buffer[buflen], "Currently ignoring CPU '%s'", machine->cpu[cpunum]->tag); - else - buflen += sprintf(&buffer[buflen], ", '%s'", machine->cpu[cpunum]->tag); - } + /* build up a comma-separated list */ + if ((cpuinfo->flags & DEBUG_FLAG_OBSERVING) == 0) + { + if (buflen == 0) + buflen += sprintf(&buffer[buflen], "Currently ignoring CPU '%s'", cpu->tag); + else + buflen += sprintf(&buffer[buflen], ", '%s'", cpu->tag); } + } /* special message for none */ if (buflen == 0) @@ -920,11 +919,10 @@ static void execute_ignore(running_machine *machine, int ref, int params, const for (paramnum = 0; paramnum < params; paramnum++) { /* make sure this isn't the last live CPU */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL && machine->cpu[cpunum] != cpuwhich[paramnum]) - if ((cpu_get_debug_data(machine->cpu[cpunum])->flags & DEBUG_FLAG_OBSERVING) != 0) - break; - if (cpunum == ARRAY_LENGTH(machine->cpu)) + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + if (cpu != cpuwhich[paramnum] && (cpu_get_debug_data(cpu)->flags & DEBUG_FLAG_OBSERVING) != 0) + break; + if (cpu == NULL) { debug_console_printf(machine, "Can't ignore all CPUs!\n"); return; @@ -944,7 +942,8 @@ static void execute_ignore(running_machine *machine, int ref, int params, const static void execute_observe(running_machine *machine, int ref, int params, const char *param[]) { const device_config *cpuwhich[MAX_COMMAND_PARAMS]; - int cpunum, paramnum; + const device_config *cpu; + int paramnum; char buffer[100]; int buflen = 0; @@ -952,20 +951,19 @@ static void execute_observe(running_machine *machine, int ref, int params, const if (params == 0) { /* loop over all CPUs */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) - { - const cpu_debug_data *cpuinfo = cpu_get_debug_data(machine->cpu[cpunum]); + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + { + const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); - /* build up a comma-separated list */ - if ((cpuinfo->flags & DEBUG_FLAG_OBSERVING) != 0) - { - if (buflen == 0) - buflen += sprintf(&buffer[buflen], "Currently observing CPU '%s'", machine->cpu[cpunum]->tag); - else - buflen += sprintf(&buffer[buflen], ", '%s'", machine->cpu[cpunum]->tag); - } + /* build up a comma-separated list */ + if ((cpuinfo->flags & DEBUG_FLAG_OBSERVING) != 0) + { + if (buflen == 0) + buflen += sprintf(&buffer[buflen], "Currently observing CPU '%s'", cpu->tag); + else + buflen += sprintf(&buffer[buflen], ", '%s'", cpu->tag); } + } /* special message for none */ if (buflen == 0) @@ -1103,16 +1101,15 @@ static void execute_bpclear(running_machine *machine, int ref, int params, const /* if 0 parameters, clear all */ if (params == 0) { - int cpunum; + const device_config *cpu; - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) - { - const cpu_debug_data *cpuinfo = cpu_get_debug_data(machine->cpu[cpunum]); - debug_cpu_breakpoint *bp; - while ((bp = cpuinfo->bplist) != NULL) - debug_cpu_breakpoint_clear(machine, bp->index); - } + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + { + const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); + debug_cpu_breakpoint *bp; + while ((bp = cpuinfo->bplist) != NULL) + debug_cpu_breakpoint_clear(machine, bp->index); + } debug_console_printf(machine, "Cleared all breakpoints\n"); } @@ -1142,16 +1139,15 @@ static void execute_bpdisenable(running_machine *machine, int ref, int params, c /* if 0 parameters, clear all */ if (params == 0) { - int cpunum; + const device_config *cpu; - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) - { - const cpu_debug_data *cpuinfo = cpu_get_debug_data(machine->cpu[cpunum]); - debug_cpu_breakpoint *bp; - for (bp = cpuinfo->bplist; bp != NULL; bp = bp->next) - debug_cpu_breakpoint_enable(machine, bp->index, ref); - } + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + { + const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); + debug_cpu_breakpoint *bp; + for (bp = cpuinfo->bplist; bp != NULL; bp = bp->next) + debug_cpu_breakpoint_enable(machine, bp->index, ref); + } if (ref == 0) debug_console_printf(machine, "Disabled all breakpoints\n"); else @@ -1179,35 +1175,35 @@ static void execute_bpdisenable(running_machine *machine, int ref, int params, c static void execute_bplist(running_machine *machine, int ref, int params, const char *param[]) { - int cpunum, printed = 0; + const device_config *cpu; + int printed = 0; char buffer[256]; /* loop over all CPUs */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + { + const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); + + if (cpuinfo->bplist != NULL) { - const cpu_debug_data *cpuinfo = cpu_get_debug_data(machine->cpu[cpunum]); + debug_cpu_breakpoint *bp; - if (cpuinfo->bplist != NULL) + debug_console_printf(machine, "CPU '%s' breakpoints:\n", cpu->tag); + + /* loop over the breakpoints */ + for (bp = cpuinfo->bplist; bp != NULL; bp = bp->next) { - debug_cpu_breakpoint *bp; - - debug_console_printf(machine, "CPU %d breakpoints:\n", cpunum); - - /* loop over the breakpoints */ - for (bp = cpuinfo->bplist; bp != NULL; bp = bp->next) - { - int buflen; - buflen = sprintf(buffer, "%c%4X @ %08X", bp->enabled ? ' ' : 'D', bp->index, bp->address); - if (bp->condition) - buflen += sprintf(&buffer[buflen], " if %s", expression_original_string(bp->condition)); - if (bp->action) - buflen += sprintf(&buffer[buflen], " do %s", bp->action); - debug_console_printf(machine, "%s\n", buffer); - printed++; - } + int buflen; + buflen = sprintf(buffer, "%c%4X @ %08X", bp->enabled ? ' ' : 'D', bp->index, bp->address); + if (bp->condition) + buflen += sprintf(&buffer[buflen], " if %s", expression_original_string(bp->condition)); + if (bp->action) + buflen += sprintf(&buffer[buflen], " do %s", bp->action); + debug_console_printf(machine, "%s\n", buffer); + printed++; } } + } if (!printed) debug_console_printf(machine, "No breakpoints currently installed\n"); @@ -1279,21 +1275,20 @@ static void execute_wpclear(running_machine *machine, int ref, int params, const /* if 0 parameters, clear all */ if (params == 0) { - int cpunum; + const device_config *cpu; - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + { + const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); + int spacenum; + + for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) { - const cpu_debug_data *cpuinfo = cpu_get_debug_data(machine->cpu[cpunum]); - int spacenum; - - for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) - { - debug_cpu_watchpoint *wp; - while ((wp = cpuinfo->wplist[spacenum]) != NULL) - debug_cpu_watchpoint_clear(machine, wp->index); - } + debug_cpu_watchpoint *wp; + while ((wp = cpuinfo->wplist[spacenum]) != NULL) + debug_cpu_watchpoint_clear(machine, wp->index); } + } debug_console_printf(machine, "Cleared all watchpoints\n"); } @@ -1323,21 +1318,20 @@ static void execute_wpdisenable(running_machine *machine, int ref, int params, c /* if 0 parameters, clear all */ if (params == 0) { - int cpunum; + const device_config *cpu; - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + { + const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); + int spacenum; + + for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) { - const cpu_debug_data *cpuinfo = cpu_get_debug_data(machine->cpu[cpunum]); - int spacenum; - - for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) - { - debug_cpu_watchpoint *wp; - for (wp = cpuinfo->wplist[spacenum]; wp != NULL; wp = wp->next) - debug_cpu_watchpoint_enable(machine, wp->index, ref); - } + debug_cpu_watchpoint *wp; + for (wp = cpuinfo->wplist[spacenum]; wp != NULL; wp = wp->next) + debug_cpu_watchpoint_enable(machine, wp->index, ref); } + } if (ref == 0) debug_console_printf(machine, "Disabled all watchpoints\n"); else @@ -1365,40 +1359,40 @@ static void execute_wpdisenable(running_machine *machine, int ref, int params, c static void execute_wplist(running_machine *machine, int ref, int params, const char *param[]) { - int cpunum, printed = 0; + const device_config *cpu; + int printed = 0; char buffer[256]; /* loop over all CPUs */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) - { - const cpu_debug_data *cpuinfo = cpu_get_debug_data(machine->cpu[cpunum]); - int spacenum; + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + { + const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); + int spacenum; - for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) - if (cpuinfo->wplist[spacenum] != NULL) + for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) + if (cpuinfo->wplist[spacenum] != NULL) + { + static const char *const types[] = { "unkn ", "read ", "write", "r/w " }; + const address_space *space = cpu_get_address_space(cpu, spacenum); + debug_cpu_watchpoint *wp; + + debug_console_printf(machine, "CPU '%s' %s space watchpoints:\n", cpu->tag, address_space_names[spacenum]); + + /* loop over the watchpoints */ + for (wp = cpuinfo->wplist[spacenum]; wp != NULL; wp = wp->next) { - static const char *const types[] = { "unkn ", "read ", "write", "r/w " }; - const address_space *space = cpu_get_address_space(machine->cpu[cpunum], spacenum); - debug_cpu_watchpoint *wp; - - debug_console_printf(machine, "CPU '%s' %s space watchpoints:\n", space->cpu->tag, address_space_names[spacenum]); - - /* loop over the watchpoints */ - for (wp = cpuinfo->wplist[spacenum]; wp != NULL; wp = wp->next) - { - int buflen; - buflen = sprintf(buffer, "%c%4X @ %08X-%08X %s", wp->enabled ? ' ' : 'D', - wp->index, memory_byte_to_address(space, wp->address), memory_byte_to_address_end(space, wp->address + wp->length) - 1, types[wp->type & 3]); - if (wp->condition) - buflen += sprintf(&buffer[buflen], " if %s", expression_original_string(wp->condition)); - if (wp->action) - buflen += sprintf(&buffer[buflen], " do %s", wp->action); - debug_console_printf(machine, "%s\n", buffer); - printed++; - } + int buflen; + buflen = sprintf(buffer, "%c%4X @ %08X-%08X %s", wp->enabled ? ' ' : 'D', + wp->index, memory_byte_to_address(space, wp->address), memory_byte_to_address_end(space, wp->address + wp->length) - 1, types[wp->type & 3]); + if (wp->condition) + buflen += sprintf(&buffer[buflen], " if %s", expression_original_string(wp->condition)); + if (wp->action) + buflen += sprintf(&buffer[buflen], " do %s", wp->action); + debug_console_printf(machine, "%s\n", buffer); + printed++; } - } + } + } if (!printed) debug_console_printf(machine, "No watchpoints currently installed\n"); @@ -1420,21 +1414,19 @@ static void execute_hotspot(running_machine *machine, int ref, int params, const if (params == 0) { int cleared = FALSE; - int cpunum; /* loop over CPUs and find live spots */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) - { - const cpu_debug_data *cpuinfo = cpu_get_debug_data(machine->cpu[cpunum]); + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + { + const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); - if (cpuinfo->hotspots != NULL) - { - debug_cpu_hotspot_track(cpuinfo->device, 0, 0); - debug_console_printf(machine, "Cleared hotspot tracking on CPU '%s'\n", machine->cpu[cpunum]->tag); - cleared = TRUE; - } + if (cpuinfo->hotspots != NULL) + { + debug_cpu_hotspot_track(cpuinfo->device, 0, 0); + debug_console_printf(machine, "Cleared hotspot tracking on CPU '%s'\n", cpu->tag); + cleared = TRUE; } + } /* if we cleared, we're done */ if (cleared) diff --git a/src/emu/debug/debugcpu.c b/src/emu/debug/debugcpu.c index b5aadefb295..291af6d3515 100644 --- a/src/emu/debug/debugcpu.c +++ b/src/emu/debug/debugcpu.c @@ -160,7 +160,8 @@ void debug_cpu_init(running_machine *machine) { const device_config *first_screen = video_screen_first(machine->config); debugcpu_private *global; - int cpunum, regnum; + const device_config *cpu; + int regnum; /* allocate and reset globals */ machine->debugcpu_data = global = auto_malloc(sizeof(*global)); @@ -189,68 +190,66 @@ void debug_cpu_init(running_machine *machine) } /* loop over CPUs and build up their info */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + { + cpu_class_header *classheader = cpu_get_class_header(cpu); + cpu_debug_data *info; + + /* allocate some information */ + info = auto_malloc(sizeof(*info)); + memset(info, 0, sizeof(*info)); + classheader->debug = info; + + /* reset the PC data */ + info->flags = DEBUG_FLAG_OBSERVING | DEBUG_FLAG_HISTORY; + info->device = cpu; + info->opwidth = cpu_get_min_opcode_bytes(info->device); + + /* fetch the memory accessors */ + info->read = (cpu_read_func)cpu_get_info_fct(info->device, CPUINFO_PTR_READ); + info->write = (cpu_write_func)cpu_get_info_fct(info->device, CPUINFO_PTR_WRITE); + info->readop = (cpu_readop_func)cpu_get_info_fct(info->device, CPUINFO_PTR_READOP); + + /* allocate a symbol table */ + info->symtable = symtable_alloc(global->symtable, (void *)cpu); + + /* add a global symbol for the current instruction pointer */ + symtable_add_register(info->symtable, "curpc", NULL, get_current_pc, 0); + symtable_add_register(info->symtable, "cycles", NULL, get_cycles, NULL); + if (classheader->space[ADDRESS_SPACE_PROGRAM] != NULL) + symtable_add_register(info->symtable, "logunmap", (void *)classheader->space[ADDRESS_SPACE_PROGRAM], get_logunmap, set_logunmap); + if (classheader->space[ADDRESS_SPACE_DATA] != NULL) + symtable_add_register(info->symtable, "logunmapd", (void *)classheader->space[ADDRESS_SPACE_DATA], get_logunmap, set_logunmap); + if (classheader->space[ADDRESS_SPACE_IO] != NULL) + symtable_add_register(info->symtable, "logunmapi", (void *)classheader->space[ADDRESS_SPACE_IO], get_logunmap, set_logunmap); + + /* add all registers into it */ + for (regnum = 0; regnum < MAX_REGS; regnum++) { - const device_config *cpu = machine->cpu[cpunum]; - cpu_class_header *classheader = cpu->classtoken; - cpu_debug_data *info; + const char *str = cpu_get_reg_string(info->device, regnum); + const char *colon; + char symname[256]; + int charnum; - /* allocate some information */ - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); - classheader->debug = info; + /* skip if we don't get a valid string, or one without a colon */ + if (str == NULL) + continue; + if (str[0] == '~') + str++; + colon = strchr(str, ':'); + if (colon == NULL) + continue; - /* reset the PC data */ - info->flags = DEBUG_FLAG_OBSERVING | DEBUG_FLAG_HISTORY; - info->device = machine->cpu[cpunum]; - info->opwidth = cpu_get_min_opcode_bytes(info->device); + /* strip all spaces from the name and convert to lowercase */ + for (charnum = 0; charnum < sizeof(symname) - 1 && str < colon; str++) + if (!isspace(*str)) + symname[charnum++] = tolower(*str); + symname[charnum] = 0; - /* fetch the memory accessors */ - info->read = (cpu_read_func)cpu_get_info_fct(info->device, CPUINFO_PTR_READ); - info->write = (cpu_write_func)cpu_get_info_fct(info->device, CPUINFO_PTR_WRITE); - info->readop = (cpu_readop_func)cpu_get_info_fct(info->device, CPUINFO_PTR_READOP); - - /* allocate a symbol table */ - info->symtable = symtable_alloc(global->symtable, (void *)cpu); - - /* add a global symbol for the current instruction pointer */ - symtable_add_register(info->symtable, "curpc", NULL, get_current_pc, 0); - symtable_add_register(info->symtable, "cycles", NULL, get_cycles, NULL); - if (classheader->space[ADDRESS_SPACE_PROGRAM] != NULL) - symtable_add_register(info->symtable, "logunmap", (void *)classheader->space[ADDRESS_SPACE_PROGRAM], get_logunmap, set_logunmap); - if (classheader->space[ADDRESS_SPACE_DATA] != NULL) - symtable_add_register(info->symtable, "logunmapd", (void *)classheader->space[ADDRESS_SPACE_DATA], get_logunmap, set_logunmap); - if (classheader->space[ADDRESS_SPACE_IO] != NULL) - symtable_add_register(info->symtable, "logunmapi", (void *)classheader->space[ADDRESS_SPACE_IO], get_logunmap, set_logunmap); - - /* add all registers into it */ - for (regnum = 0; regnum < MAX_REGS; regnum++) - { - const char *str = cpu_get_reg_string(info->device, regnum); - const char *colon; - char symname[256]; - int charnum; - - /* skip if we don't get a valid string, or one without a colon */ - if (str == NULL) - continue; - if (str[0] == '~') - str++; - colon = strchr(str, ':'); - if (colon == NULL) - continue; - - /* strip all spaces from the name and convert to lowercase */ - for (charnum = 0; charnum < sizeof(symname) - 1 && str < colon; str++) - if (!isspace(*str)) - symname[charnum++] = tolower(*str); - symname[charnum] = 0; - - /* add the symbol to the table */ - symtable_add_register(info->symtable, symname, (void *)(FPTR)regnum, get_cpu_reg, set_cpu_reg); - } + /* add the symbol to the table */ + symtable_add_register(info->symtable, symname, (void *)(FPTR)regnum, get_cpu_reg, set_cpu_reg); } + } /* first CPU is visible by default */ global->visiblecpu = machine->cpu[0]; @@ -271,18 +270,17 @@ void debug_cpu_init(running_machine *machine) void debug_cpu_flush_traces(running_machine *machine) { - int cpunum; + const device_config *cpu; - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) - { - cpu_debug_data *info = cpu_get_debug_data(machine->cpu[cpunum]); + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + { + cpu_debug_data *info = cpu_get_debug_data(cpu); - /* this can be called on exit even when no debugging is enabled, so - make sure the info is valid before proceeding */ - if (info != NULL && info->trace.file != NULL) - fflush(info->trace.file); - } + /* this can be called on exit even when no debugging is enabled, so + make sure the info is valid before proceeding */ + if (info != NULL && info->trace.file != NULL) + fflush(info->trace.file); + } } @@ -923,34 +921,33 @@ int debug_cpu_breakpoint_set(const device_config *device, offs_t address, parsed int debug_cpu_breakpoint_clear(running_machine *machine, int bpnum) { debug_cpu_breakpoint *bp, *pbp; - int cpunum; + const device_config *cpu; /* loop over CPUs and find the requested breakpoint */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) - { - cpu_debug_data *info = cpu_get_debug_data(machine->cpu[cpunum]); - for (pbp = NULL, bp = info->bplist; bp != NULL; pbp = bp, bp = bp->next) - if (bp->index == bpnum) - { - /* unlink us from the list */ - if (pbp == NULL) - info->bplist = bp->next; - else - pbp->next = bp->next; + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + { + cpu_debug_data *info = cpu_get_debug_data(cpu); + for (pbp = NULL, bp = info->bplist; bp != NULL; pbp = bp, bp = bp->next) + if (bp->index == bpnum) + { + /* unlink us from the list */ + if (pbp == NULL) + info->bplist = bp->next; + else + pbp->next = bp->next; - /* free the memory */ - if (bp->condition != NULL) - expression_free(bp->condition); - if (bp->action != NULL) - free(bp->action); - free(bp); + /* free the memory */ + if (bp->condition != NULL) + expression_free(bp->condition); + if (bp->action != NULL) + free(bp->action); + free(bp); - /* update the flags */ - breakpoint_update_flags(info); - return TRUE; - } - } + /* update the flags */ + breakpoint_update_flags(info); + return TRUE; + } + } /* we didn't find it; return an error */ return FALSE; @@ -965,21 +962,20 @@ int debug_cpu_breakpoint_clear(running_machine *machine, int bpnum) int debug_cpu_breakpoint_enable(running_machine *machine, int bpnum, int enable) { debug_cpu_breakpoint *bp; - int cpunum; + const device_config *cpu; /* loop over CPUs and find the requested breakpoint */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) - { - cpu_debug_data *info = cpu_get_debug_data(machine->cpu[cpunum]); - for (bp = info->bplist; bp != NULL; bp = bp->next) - if (bp->index == bpnum) - { - bp->enabled = (enable != 0); - breakpoint_update_flags(info); - return TRUE; - } - } + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + { + cpu_debug_data *info = cpu_get_debug_data(cpu); + for (bp = info->bplist; bp != NULL; bp = bp->next) + if (bp->index == bpnum) + { + bp->enabled = (enable != 0); + breakpoint_update_flags(info); + return TRUE; + } + } return FALSE; } @@ -1033,34 +1029,34 @@ int debug_cpu_watchpoint_set(const address_space *space, int type, offs_t addres int debug_cpu_watchpoint_clear(running_machine *machine, int wpnum) { debug_cpu_watchpoint *wp, *pwp; - int cpunum, spacenum; + const device_config *cpu; + int spacenum; /* loop over CPUs and find the requested watchpoint */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) - { - cpu_debug_data *info = cpu_get_debug_data(machine->cpu[cpunum]); + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + { + cpu_debug_data *info = cpu_get_debug_data(cpu); - for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) - for (pwp = NULL, wp = info->wplist[spacenum]; wp != NULL; pwp = wp, wp = wp->next) - if (wp->index == wpnum) - { - /* unlink us from the list */ - if (pwp == NULL) - info->wplist[spacenum] = wp->next; - else - pwp->next = wp->next; + for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) + for (pwp = NULL, wp = info->wplist[spacenum]; wp != NULL; pwp = wp, wp = wp->next) + if (wp->index == wpnum) + { + /* unlink us from the list */ + if (pwp == NULL) + info->wplist[spacenum] = wp->next; + else + pwp->next = wp->next; - /* free the memory */ - if (wp->condition != NULL) - expression_free(wp->condition); - if (wp->action != NULL) - free(wp->action); - free(wp); + /* free the memory */ + if (wp->condition != NULL) + expression_free(wp->condition); + if (wp->action != NULL) + free(wp->action); + free(wp); - watchpoint_update_flags(cpu_get_address_space(machine->cpu[cpunum], spacenum)); - return TRUE; - } + watchpoint_update_flags(cpu_get_address_space(cpu, spacenum)); + return TRUE; + } } /* we didn't find it; return an error */ @@ -1076,23 +1072,23 @@ int debug_cpu_watchpoint_clear(running_machine *machine, int wpnum) int debug_cpu_watchpoint_enable(running_machine *machine, int wpnum, int enable) { debug_cpu_watchpoint *wp; - int cpunum, spacenum; + const device_config *cpu; + int spacenum; /* loop over CPUs and address spaces and find the requested watchpoint */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) - { - cpu_debug_data *info = cpu_get_debug_data(machine->cpu[cpunum]); + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + { + cpu_debug_data *info = cpu_get_debug_data(cpu); - for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) - for (wp = info->wplist[spacenum]; wp != NULL; wp = wp->next) - if (wp->index == wpnum) - { - wp->enabled = (enable != 0); - watchpoint_update_flags(cpu_get_address_space(machine->cpu[cpunum], spacenum)); - return TRUE; - } - } + for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) + for (wp = info->wplist[spacenum]; wp != NULL; wp = wp->next) + if (wp->index == wpnum) + { + wp->enabled = (enable != 0); + watchpoint_update_flags(cpu_get_address_space(cpu, spacenum)); + return TRUE; + } + } return FALSE; } @@ -1770,36 +1766,36 @@ UINT64 debug_read_opcode(const address_space *space, offs_t address, int size, i static void debug_cpu_exit(running_machine *machine) { debugcpu_private *global = machine->debugcpu_data; - int cpunum, spacenum; + const device_config *cpu; + int spacenum; /* loop over all watchpoints and breakpoints to free their memory */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + { + cpu_debug_data *info = cpu_get_debug_data(cpu); + + /* close any tracefiles */ + if (info->trace.file != NULL) + fclose(info->trace.file); + if (info->trace.action != NULL) + free(info->trace.action); + + /* free the symbol table */ + if (info->symtable != NULL) + symtable_free(info->symtable); + + /* free all breakpoints */ + while (info->bplist != NULL) + debug_cpu_breakpoint_clear(machine, info->bplist->index); + + /* loop over all address spaces */ + for (spacenum = 0; spacenum < ARRAY_LENGTH(info->wplist); spacenum++) { - cpu_debug_data *info = cpu_get_debug_data(machine->cpu[cpunum]); - - /* close any tracefiles */ - if (info->trace.file != NULL) - fclose(info->trace.file); - if (info->trace.action != NULL) - free(info->trace.action); - - /* free the symbol table */ - if (info->symtable != NULL) - symtable_free(info->symtable); - - /* free all breakpoints */ - while (info->bplist != NULL) - debug_cpu_breakpoint_clear(machine, info->bplist->index); - - /* loop over all address spaces */ - for (spacenum = 0; spacenum < ARRAY_LENGTH(info->wplist); spacenum++) - { - /* free all watchpoints */ - while (info->wplist[spacenum] != NULL) - debug_cpu_watchpoint_clear(machine, info->wplist[spacenum]->index); - } + /* free all watchpoints */ + while (info->wplist[spacenum] != NULL) + debug_cpu_watchpoint_clear(machine, info->wplist[spacenum]->index); } + } /* free the global symbol table */ if (global != NULL && global->symtable != NULL) @@ -1826,12 +1822,11 @@ static void on_vblank(const device_config *device, void *param, int vblank_state static void reset_transient_flags(running_machine *machine) { - int cpunum; + const device_config *cpu; /* loop over CPUs and reset the transient flags */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) - cpu_get_debug_data(machine->cpu[cpunum])->flags &= ~DEBUG_FLAG_TRANSIENT; + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + cpu_get_debug_data(cpu)->flags &= ~DEBUG_FLAG_TRANSIENT; } diff --git a/src/emu/debug/debughlp.c b/src/emu/debug/debughlp.c index f9c1a4e038d..9b3638f822a 100644 --- a/src/emu/debug/debughlp.c +++ b/src/emu/debug/debughlp.c @@ -78,7 +78,7 @@ static const help_item static_help_list[] = "\n" " help [] -- get help on a particular topic\n" " do -- evaluates the given expression\n" - " symlist [] -- lists registered symbols\n" + " symlist [] -- lists registered symbols\n" " softreset -- executes a soft reset\n" " hardreset -- executes a hard reset\n" " print [,...] -- prints one or more s to the console\n" @@ -95,16 +95,16 @@ static const help_item static_help_list[] = "Memory Commands\n" "Type help for further details on each command\n" "\n" - " dasm ,
,[,[,]] -- disassemble to the given file\n" + " dasm ,
,[,[,]] -- disassemble to the given file\n" " f[ind]
,[,[,...]] -- search program memory for data\n" " f[ind]d
,[,[,...]] -- search data memory for data\n" " f[ind]i
,[,[,...]] -- search I/O memory for data\n" - " dump ,
,[,[,[,]]] -- dump program memory as text\n" - " dumpd ,
,[,[,[,]]] -- dump data memory as text\n" - " dumpi ,
,[,[,[,]]] -- dump I/O memory as text\n" - " save ,
,[,] -- save binary program memory to the given file\n" - " saved ,
,[,] -- save binary data memory to the given file\n" - " savei ,
,[,] -- save binary I/O memory to the given file\n" + " dump ,
,[,[,[,]]] -- dump program memory as text\n" + " dumpd ,
,[,[,[,]]] -- dump data memory as text\n" + " dumpi ,
,[,[,[,]]] -- dump I/O memory as text\n" + " save ,
,[,] -- save binary program memory to the given file\n" + " saved ,
,[,] -- save binary data memory to the given file\n" + " savei ,
,[,] -- save binary I/O memory to the given file\n" " map
-- map logical program address to physical address and bank\n" " mapd
-- map logical data address to physical address and bank\n" " mapi
-- map logical I/O address to physical address and bank\n" @@ -124,11 +124,11 @@ static const help_item static_help_list[] = " gt[ime] -- resumes execution until the given delay has elapsed\n" " gv[blank] -- resumes execution, setting temp breakpoint on the next VBLANK (F8)\n" " n[ext] -- executes until the next CPU switch (F6)\n" - " focus -- focuses debugger only on \n" - " ignore [[,[,...]]] -- stops debugging on \n" - " observe [[,[,...]]] -- resumes debugging on \n" - " trace {|OFF}[,[,]] -- trace the given CPU to a file (defaults to active CPU)\n" - " traceover {|OFF}[,[,]] -- trace the given CPU to a file, but skip subroutines (defaults to active CPU)\n" + " focus -- focuses debugger only on \n" + " ignore [[,[,...]]] -- stops debugging on \n" + " observe [[,[,...]]] -- resumes debugging on \n" + " trace {|OFF}[,[,]] -- trace the given CPU to a file (defaults to active CPU)\n" + " traceover {|OFF}[,[,]] -- trace the given CPU to a file, but skip subroutines (defaults to active CPU)\n" " traceflush -- flushes all open trace files\n" }, { @@ -156,7 +156,7 @@ static const help_item static_help_list[] = " wpdisable [] -- disables a given watchpoint or all if no specified\n" " wpenable [] -- enables a given watchpoint or all if no specified\n" " wplist -- lists all the watchpoints\n" - " hotspot [,[[,]]] -- attempt to find hotspots\n" + " hotspot [,[[,]]] -- attempt to find hotspots\n" }, { "expressions", @@ -219,10 +219,10 @@ static const help_item static_help_list[] = { "symlist", "\n" - " symlist []\n" + " symlist []\n" "\n" - "Lists registered symbols. If is not specified, then symbols in the global symbol table are " - "displayed; otherwise, the symbols for 's specific CPU are displayed. Symbols are listed " + "Lists registered symbols. If is not specified, then symbols in the global symbol table are " + "displayed; otherwise, the symbols for 's specific CPU are displayed. Symbols are listed " "alphabetically. Read-only symbols are flagged with an asterisk.\n" "\n" "Examples:\n" @@ -377,14 +377,14 @@ static const help_item static_help_list[] = { "dasm", "\n" - " dasm ,
,[,[,]]\n" + " dasm ,
,[,[,]]\n" "\n" "The dasm command disassembles program memory to the file specified in the parameter. " "
indicates the address of the start of disassembly, and indicates how much " "memory to disassemble. The range
through
+-1 inclusive will be " "output to the file. By default, the raw opcode data is output with each line. The optional " " parameter can be used to enable (1) or disable(0) this feature. Finally, you can " - "disassemble code from another CPU by specifying the parameter.\n" + "disassemble code from another CPU by specifying the parameter.\n" "\n" "Examples:\n" "\n" @@ -431,7 +431,7 @@ static const help_item static_help_list[] = { "dump", "\n" - " dump[{d|i}] ,
,[,[,[,]]]\n" + " dump[{d|i}] ,
,[,[,[,]]]\n" "\n" "The dump/dumpd/dumpi commands dump memory to the text file specified in the " "parameter. 'dump' will dump program space memory, while 'dumpd' will dump data space memory " @@ -442,7 +442,7 @@ static const help_item static_help_list[] = " parameter, which can be used to group the data in 1, 2, 4 or 8-byte chunks. The optional " " parameter can be used to enable (1) or disable (0) the output of ASCII characters to the " "right of each line; by default, this is enabled. Finally, you can dump memory from another CPU " - "by specifying the parameter.\n" + "by specifying the parameter.\n" "\n" "Examples:\n" "\n" @@ -457,14 +457,14 @@ static const help_item static_help_list[] = { "save", "\n" - " save[{d|i}] ,
,[,]\n" + " save[{d|i}] ,
,[,]\n" "\n" "The save/saved/savei commands save raw memory to the binary file specified in the " "parameter. 'save' will save program space memory, while 'saved' will save data space memory " "and 'savei' will save I/O space memory.
indicates the address of the start of saving, " "and indicates how much memory to save. The range
through
+-1 " "inclusive will be output to the file. You can also save memory from another CPU by specifying the " - " parameter.\n" + " parameter.\n" "\n" "Examples:\n" "\n" @@ -610,9 +610,9 @@ static const help_item static_help_list[] = { "focus", "\n" - " focus \n" + " focus \n" "\n" - "Sets the debugger focus exclusively to the given . This is equivalent to specifying " + "Sets the debugger focus exclusively to the given . This is equivalent to specifying " "'ignore' on all other CPUs.\n" "\n" "Examples:\n" @@ -623,11 +623,11 @@ static const help_item static_help_list[] = { "ignore", "\n" - " ignore [[,[,...]]]\n" + " ignore [[,[,...]]]\n" "\n" - "Ignores the specified in the debugger. This means that you won't ever see execution " + "Ignores the specified in the debugger. This means that you won't ever see execution " "on that CPU, nor will you be able to set breakpoints on that CPU. To undo this change use " - "the 'observe' command. You can specify multiple s in a single command. Note also that " + "the 'observe' command. You can specify multiple s in a single command. Note also that " "you are not permitted to ignore all CPUs; at least one must be active at all times.\n" "\n" "Examples:\n" @@ -644,10 +644,10 @@ static const help_item static_help_list[] = { "observe", "\n" - " observe [[,[,...]]]\n" + " observe [[,[,...]]]\n" "\n" - "Re-enables interaction with the specified in the debugger. This command undoes the " - "effects of the 'ignore' command. You can specify multiple s in a single command.\n" + "Re-enables interaction with the specified in the debugger. This command undoes the " + "effects of the 'ignore' command. You can specify multiple s in a single command.\n" "\n" "Examples:\n" "\n" @@ -663,9 +663,9 @@ static const help_item static_help_list[] = { "trace", "\n" - " trace {|OFF}[,[,]]\n" + " trace {|OFF}[,[,]]\n" "\n" - "Starts or stops tracing of the execution of the specified . If is omitted, " + "Starts or stops tracing of the execution of the specified . If is omitted, " "the currently active CPU is specified. When enabling tracing, specify the filename in the " " parameter. To disable tracing, substitute the keyword 'off' for . If you " "wish to log additional information on each trace, you can append an parameter which " @@ -695,13 +695,13 @@ static const help_item static_help_list[] = { "traceover", "\n" - " traceover {|OFF}[,[,]]\n" + " traceover {|OFF}[,[,]]\n" "\n" - "Starts or stops tracing of the execution of the specified . When tracing reaches " + "Starts or stops tracing of the execution of the specified . When tracing reaches " "a subroutine or call, tracing will skip over the subroutine. The same algorithm is used as is " "used in the step over command. This means that traceover will not work properly when calls " "are recusive or the return address is not immediately following the call instruction. If " - " is omitted, the currently active CPU is specified. When enabling tracing, specify the " + " is omitted, the currently active CPU is specified. When enabling tracing, specify the " "filename in the parameter. To disable tracing, substitute the keyword 'off' for " ". If you wish to log additional information on each trace, you can append an " "parameter which is a command that is executed before each trace is logged. Generally, this is " @@ -929,10 +929,10 @@ static const help_item static_help_list[] = { "hotspot", "\n" - " hotspot [,[[,]]]\n" + " hotspot [,[[,]]]\n" "\n" "The hotspot command attempts to help locate hotspots in the code where speedup opportunities " - "might be present. , which defaults to the currently active CPU, specified which " + "might be present. , which defaults to the currently active CPU, specified which " "processor's memory to track. , which defaults to 64, controls the depth of the search " "buffer. The search buffer tracks the last memory reads from unique PCs. The " "parameter, which defaults to 250, specifies the minimum number of hits to report.\n" diff --git a/src/emu/debug/debugvw.c b/src/emu/debug/debugvw.c index cd9b05698bf..7c60e86b0a0 100644 --- a/src/emu/debug/debugvw.c +++ b/src/emu/debug/debugvw.c @@ -1043,31 +1043,29 @@ static const registers_subview_item *registers_view_enumerate_subviews(running_m astring *tempstring = astring_alloc(); registers_subview_item *head = NULL; registers_subview_item **tailptr = &head; + const device_config *cpu; int curindex = 0; - int cpunum; /* iterate over CPUs with program address spaces */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) - { - const device_config *device = machine->cpu[cpunum]; - registers_subview_item *subview; + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + { + registers_subview_item *subview; - /* determine the string and allocate a subview large enough */ - astring_printf(tempstring, "CPU '%s' (%s)", device->tag, cpu_get_name(device)); - subview = auto_malloc(sizeof(*subview) + astring_len(tempstring)); - memset(subview, 0, sizeof(*subview)); + /* determine the string and allocate a subview large enough */ + astring_printf(tempstring, "CPU '%s' (%s)", cpu->tag, cpu_get_name(cpu)); + subview = auto_malloc(sizeof(*subview) + astring_len(tempstring)); + memset(subview, 0, sizeof(*subview)); - /* populate the subview */ - subview->next = NULL; - subview->index = curindex++; - subview->device = device; - strcpy(subview->name, astring_c(tempstring)); + /* populate the subview */ + subview->next = NULL; + subview->index = curindex++; + subview->device = cpu; + strcpy(subview->name, astring_c(tempstring)); - /* add to the list */ - *tailptr = subview; - tailptr = &subview->next; - } + /* add to the list */ + *tailptr = subview; + tailptr = &subview->next; + } /* free the temporary string */ astring_free(tempstring); @@ -1488,34 +1486,33 @@ static const disasm_subview_item *disasm_view_enumerate_subviews(running_machine astring *tempstring = astring_alloc(); disasm_subview_item *head = NULL; disasm_subview_item **tailptr = &head; + const device_config *cpu; int curindex = 0; - int cpunum; /* iterate over CPUs with program address spaces */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + { + const address_space *space = cpu_get_address_space(cpu, ADDRESS_SPACE_PROGRAM); + if (space != NULL) { - const address_space *space = cpu_get_address_space(machine->cpu[cpunum], ADDRESS_SPACE_PROGRAM); - if (space != NULL) - { - disasm_subview_item *subview; + disasm_subview_item *subview; - /* determine the string and allocate a subview large enough */ - astring_printf(tempstring, "CPU '%s' (%s)", space->cpu->tag, cpu_get_name(space->cpu)); - subview = auto_malloc(sizeof(*subview) + astring_len(tempstring)); - memset(subview, 0, sizeof(*subview)); + /* determine the string and allocate a subview large enough */ + astring_printf(tempstring, "CPU '%s' (%s)", cpu->tag, cpu_get_name(cpu)); + subview = auto_malloc(sizeof(*subview) + astring_len(tempstring)); + memset(subview, 0, sizeof(*subview)); - /* populate the subview */ - subview->next = NULL; - subview->index = curindex++; - subview->space = space; - strcpy(subview->name, astring_c(tempstring)); + /* populate the subview */ + subview->next = NULL; + subview->index = curindex++; + subview->space = space; + strcpy(subview->name, astring_c(tempstring)); - /* add to the list */ - *tailptr = subview; - tailptr = &subview->next; - } + /* add to the list */ + *tailptr = subview; + tailptr = &subview->next; } + } /* free the temporary string */ astring_free(tempstring); @@ -1532,7 +1529,7 @@ static int disasm_view_alloc(debug_view *view) { debug_view_disasm *dasmdata; int total_comments = 0; - int cpunum; + const device_config *cpu; /* fail if no available subviews */ if (view->machine->debugvw_data->disasm_subviews == NULL) @@ -1551,9 +1548,8 @@ static int disasm_view_alloc(debug_view *view) debug_view_expression_alloc(&dasmdata->expression); /* count the number of comments */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(view->machine->cpu); cpunum++) - if (view->machine->cpu[cpunum] != NULL) - total_comments += debug_comment_get_count(view->machine->cpu[cpunum]); + for (cpu = view->machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + total_comments += debug_comment_get_count(cpu); /* initialize */ dasmdata->right_column = (total_comments > 0) ? DASM_RIGHTCOL_COMMENTS : DASM_RIGHTCOL_RAW; @@ -2406,39 +2402,39 @@ static const memory_subview_item *memory_view_enumerate_subviews(running_machine astring *tempstring = astring_alloc(); memory_subview_item *head = NULL; memory_subview_item **tailptr = &head; - int cpunum, spacenum; + const device_config *cpu; + int spacenum; const char *rgntag; int curindex = 0; int itemnum; /* first add all the CPUs' address spaces */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) - for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) + { + const address_space *space = cpu_get_address_space(cpu, spacenum); + if (space != NULL) { - const address_space *space = cpu_get_address_space(machine->cpu[cpunum], spacenum); - if (space != NULL) - { - memory_subview_item *subview; + memory_subview_item *subview; - /* determine the string and allocate a subview large enough */ - astring_printf(tempstring, "CPU '%s' (%s) %s memory", space->cpu->tag, cpu_get_name(space->cpu), space->name); - subview = auto_malloc(sizeof(*subview) + astring_len(tempstring)); - memset(subview, 0, sizeof(*subview)); + /* determine the string and allocate a subview large enough */ + astring_printf(tempstring, "CPU '%s' (%s) %s memory", cpu->tag, cpu_get_name(cpu), space->name); + subview = auto_malloc(sizeof(*subview) + astring_len(tempstring)); + memset(subview, 0, sizeof(*subview)); - /* populate the subview */ - subview->next = NULL; - subview->index = curindex++; - subview->space = space; - subview->endianness = space->endianness; - subview->prefsize = space->dbits / 8; - strcpy(subview->name, astring_c(tempstring)); + /* populate the subview */ + subview->next = NULL; + subview->index = curindex++; + subview->space = space; + subview->endianness = space->endianness; + subview->prefsize = space->dbits / 8; + strcpy(subview->name, astring_c(tempstring)); - /* add to the list */ - *tailptr = subview; - tailptr = &subview->next; - } - } + /* add to the list */ + *tailptr = subview; + tailptr = &subview->next; + } + } /* then add all the memory regions */ for (rgntag = memory_region_next(machine, NULL); rgntag != NULL; rgntag = memory_region_next(machine, rgntag)) diff --git a/src/emu/deprecat.h b/src/emu/deprecat.h index bb978605b93..63a8c684782 100644 --- a/src/emu/deprecat.h +++ b/src/emu/deprecat.h @@ -49,8 +49,9 @@ extern running_machine *Machine; *************************************/ #define MDRV_CPU_VBLANK_INT_HACK(_func, _rate) \ - TOKEN_UINT32_PACK2(MCONFIG_TOKEN_CPU_VBLANK_INT_HACK, 8, _rate, 24), \ - TOKEN_PTR(interrupt, _func), + MDRV_DEVICE_CONFIG_DATAPTR(cpu_config, vblank_interrupt, _func) \ + MDRV_DEVICE_CONFIG_DATAPTR(cpu_config, vblank_interrupt_screen, NULL) \ + MDRV_DEVICE_CONFIG_DATA32(cpu_config, vblank_interrupts_per_frame, _rate) diff --git a/src/emu/devintrf.c b/src/emu/devintrf.c index df55d972caa..a43f20ed9f1 100644 --- a/src/emu/devintrf.c +++ b/src/emu/devintrf.c @@ -82,10 +82,9 @@ INLINE int device_matches_type(const device_config *device, device_type type) device_config *device_list_add(device_config **listheadptr, device_type type, const char *tag) { - device_config **devptr; - device_config *device; + device_config **devptr, **typedevptr; + device_config *device, *typedevice; UINT32 configlen; - deviceinfo info; assert(listheadptr != NULL); assert(type != NULL); @@ -104,6 +103,7 @@ device_config *device_list_add(device_config **listheadptr, device_type type, co /* populate all fields */ device->next = NULL; + device->typenext = NULL; device->type = type; device->class = devtype_get_info_int(type, DEVINFO_INT_CLASS); device->static_config = NULL; @@ -120,25 +120,12 @@ device_config *device_list_add(device_config **listheadptr, device_type type, co memset(device->inline_config, 0, configlen); /* fetch function pointers to the core functions */ - info.set_info = NULL; - (*type)(NULL, DEVINFO_FCT_SET_INFO, &info); - device->set_info = info.set_info; + device->set_info = (device_set_info_func)devtype_get_info_fct(type, DEVINFO_FCT_SET_INFO); - info.start = NULL; - (*type)(NULL, DEVINFO_FCT_START, &info); - device->start = info.start; - - info.stop = NULL; - (*type)(NULL, DEVINFO_FCT_STOP, &info); - device->stop = info.stop; - - info.reset = NULL; - (*type)(NULL, DEVINFO_FCT_RESET, &info); - device->reset = info.reset; - - info.nvram = NULL; - (*type)(NULL, DEVINFO_FCT_NVRAM, &info); - device->nvram = info.nvram; + /* before adding us to the global list, add us to the end of the class list */ + typedevice = (device_config *)device_list_first(*listheadptr, type); + for (typedevptr = &typedevice; *typedevptr != NULL; typedevptr = &(*typedevptr)->typenext) ; + *typedevptr = device; /* link us to the end and return */ *devptr = device; @@ -153,8 +140,8 @@ device_config *device_list_add(device_config **listheadptr, device_type type, co void device_list_remove(device_config **listheadptr, device_type type, const char *tag) { - device_config **devptr; - device_config *device; + device_config **devptr, **typedevptr; + device_config *device, *typedevice; assert(listheadptr != NULL); assert(type != NULL); @@ -164,11 +151,17 @@ void device_list_remove(device_config **listheadptr, device_type type, const cha for (devptr = listheadptr; *devptr != NULL; devptr = &(*devptr)->next) if (type == (*devptr)->type && strcmp(tag, (*devptr)->tag) == 0) break; - if (*devptr == NULL) + device = *devptr; + if (device == NULL) fatalerror("Attempted to remove non-existant device: type=%s tag=%s\n", devtype_get_name(type), tag); + /* before removing us from the global list, remove us from the type list */ + typedevice = (device_config *)device_list_first(*listheadptr, type); + for (typedevptr = &typedevice; *typedevptr != device; typedevptr = &(*typedevptr)->typenext) ; + assert(*typedevptr == device); + *typedevptr = device->typenext; + /* remove the device from the list */ - device = *devptr; *devptr = device->next; /* free the device object */ @@ -267,16 +260,8 @@ const device_config *device_list_first(const device_config *listhead, device_typ const device_config *device_list_next(const device_config *prevdevice, device_type type) { - const device_config *curdev; - assert(prevdevice != NULL); - - /* scan forward starting with the item after the previous one */ - for (curdev = prevdevice->next; curdev != NULL; curdev = curdev->next) - if (device_matches_type(curdev, type)) - return curdev; - - return NULL; + return (type == DEVICE_TYPE_WILDCARD) ? prevdevice->next : prevdevice->typenext; } @@ -484,6 +469,23 @@ const device_config *device_list_class_find_by_index(const device_config *listhe LIVE DEVICE MANAGEMENT ***************************************************************************/ +/*------------------------------------------------- + device_list_attach_machine - "attach" a + running_machine to its list of devices +-------------------------------------------------*/ + +void device_list_attach_machine(running_machine *machine) +{ + device_config *device; + + assert(machine != NULL); + + /* iterate over devices and assign the machine to them */ + for (device = (device_config *)machine->config->devicelist; device != NULL; device = device->next) + device->machine = machine; +} + + /*------------------------------------------------- device_list_start - start the configured list of devices for a machine @@ -504,23 +506,24 @@ void device_list_start(running_machine *machine) /* iterate over devices and allocate memory for them */ for (device = (device_config *)machine->config->devicelist; device != NULL; device = device->next) { - UINT32 tokenlen; + deviceinfo info = { 0 }; assert(!device->started); + assert(device->machine == machine); assert(device->token == NULL); assert(device->type != NULL); - assert(device->start != NULL); devcount++; - /* get the size of the token data */ - tokenlen = (UINT32)devtype_get_info_int(device->type, DEVINFO_INT_TOKEN_BYTES); - if (tokenlen == 0) - fatalerror("Device %s specifies a 0 token length!\n", devtype_get_name(device->type)); + /* get the size of the token data; we do it directly because we can't call device_get_info_* with no token */ + (*device->type)(device, DEVINFO_INT_TOKEN_BYTES, &info); + device->tokenbytes = (UINT32)info.i; + if (device->tokenbytes == 0) + fatalerror("Device %s specifies a 0 token length!\n", device_get_name(device)); /* allocate memory for the token */ - device->token = malloc_or_die(tokenlen); - memset(device->token, 0, tokenlen); + device->token = malloc_or_die(device->tokenbytes); + memset(device->token, 0, device->tokenbytes); /* fill in the remaining runtime fields */ device->machine = machine; @@ -537,7 +540,10 @@ void device_list_start(running_machine *machine) /* iterate over devices and start them */ for (device = (device_config *)machine->config->devicelist; device != NULL; device = device->next) { - if (!device->started && (*device->start)(device) == DEVICE_START_OK) + device_start_func start = (device_start_func)device_get_info_fct(device, DEVINFO_FCT_START); + + assert(start != NULL); + if (!device->started && (*start)(device) == DEVICE_START_OK) device->started = TRUE; numstarted += device->started; } @@ -563,12 +569,14 @@ static void device_list_stop(running_machine *machine) /* iterate over devices and stop them */ for (device = (device_config *)machine->config->devicelist; device != NULL; device = device->next) { + device_stop_func stop = (device_stop_func)device_get_info_fct(device, DEVINFO_FCT_STOP); + assert(device->token != NULL); assert(device->type != NULL); /* if we have a stop function, call it */ - if (device->stop != NULL) - (*device->stop)(device); + if (stop != NULL) + (*stop)(device); /* free allocated memory for the token */ if (device->token != NULL) @@ -576,6 +584,7 @@ static void device_list_stop(running_machine *machine) /* reset all runtime fields */ device->token = NULL; + device->tokenbytes = 0; device->machine = NULL; device->region = NULL; device->regionbytes = 0; @@ -607,28 +616,16 @@ static void device_list_reset(running_machine *machine) void device_reset(const device_config *device) { + device_reset_func reset; + assert(device != NULL); assert(device->token != NULL); assert(device->type != NULL); /* if we have a reset function, call it */ - if (device->reset != NULL) - (*device->reset)(device); -} - - -void devtag_reset(running_machine *machine, device_type type, const char *tag) -{ - const device_config *device; - - assert(machine != NULL); - assert(type != NULL); - assert(tag != NULL); - - device = device_list_find_by_tag(machine->config->devicelist, type, tag); - if (device == NULL) - fatalerror("devtag_reset failed to find device: type=%s tag=%s\n", devtype_get_name(type), tag); - device_reset(device); + reset = (device_reset_func)device_get_info_fct(device, DEVINFO_FCT_RESET); + if (reset != NULL) + (*reset)(device); } @@ -637,88 +634,6 @@ void devtag_reset(running_machine *machine, device_type type, const char *tag) DEVICE INFORMATION GETTERS ***************************************************************************/ -/*------------------------------------------------- - devtag_get_token - return the token associated - with an allocated device --------------------------------------------------*/ - -void *devtag_get_token(running_machine *machine, device_type type, const char *tag) -{ - const device_config *device; - - assert(machine != NULL); - assert(type != NULL); - assert(tag != NULL); - - device = device_list_find_by_tag(machine->config->devicelist, type, tag); - if (device == NULL) - fatalerror("devtag_get_token failed to find device: type=%s tag=%s\n", devtype_get_name(type), tag); - return device->token; -} - - -/*------------------------------------------------- - devtag_get_device - return the device associated - with a tag --------------------------------------------------*/ - -const device_config *devtag_get_device(running_machine *machine, device_type type, const char *tag) -{ - const device_config *device; - - assert(machine != NULL); - assert(type != NULL); - assert(tag != NULL); - - device = device_list_find_by_tag(machine->config->devicelist, type, tag); - if (device == NULL) - fatalerror("devtag_get_device failed to find device: type=%s tag=%s\n", devtype_get_name(type), tag); - return device; -} - - -/*------------------------------------------------- - devtag_get_static_config - return a pointer to - the static configuration for a device based on - type and tag --------------------------------------------------*/ - -const void *devtag_get_static_config(running_machine *machine, device_type type, const char *tag) -{ - const device_config *device; - - assert(machine != NULL); - assert(type != NULL); - assert(tag != NULL); - - device = device_list_find_by_tag(machine->config->devicelist, type, tag); - if (device == NULL) - fatalerror("devtag_get_static_config failed to find device: type=%s tag=%s\n", devtype_get_name(type), tag); - return device->static_config; -} - - -/*------------------------------------------------- - devtag_get_inline_config - return a pointer to - the inline configuration for a device based on - type and tag --------------------------------------------------*/ - -const void *devtag_get_inline_config(running_machine *machine, device_type type, const char *tag) -{ - const device_config *device; - - assert(machine != NULL); - assert(type != NULL); - assert(tag != NULL); - - device = device_list_find_by_tag(machine->config->devicelist, type, tag); - if (device == NULL) - fatalerror("devtag_get_inline_config failed to find device: type=%s tag=%s\n", devtype_get_name(type), tag); - return device->inline_config; -} - - /*------------------------------------------------- device_get_info_int - return an integer state value from an allocated device @@ -740,22 +655,6 @@ INT64 device_get_info_int(const device_config *device, UINT32 state) } -INT64 devtag_get_info_int(running_machine *machine, device_type type, const char *tag, UINT32 state) -{ - const device_config *device; - - assert(machine != NULL); - assert(type != NULL); - assert(tag != NULL); - assert(state >= DEVINFO_INT_FIRST && state <= DEVINFO_INT_LAST); - - device = device_list_find_by_tag(machine->config->devicelist, type, tag); - if (device == NULL) - fatalerror("devtag_get_info_int failed to find device: type=%s tag=%s\n", devtype_get_name(type), tag); - return device_get_info_int(device, state); -} - - /*------------------------------------------------- device_get_info_ptr - return a pointer state value from an allocated device @@ -776,22 +675,6 @@ void *device_get_info_ptr(const device_config *device, UINT32 state) } -void *devtag_get_info_ptr(running_machine *machine, device_type type, const char *tag, UINT32 state) -{ - const device_config *device; - - assert(machine != NULL); - assert(type != NULL); - assert(tag != NULL); - assert(state >= DEVINFO_INT_FIRST && state <= DEVINFO_INT_LAST); - - device = device_list_find_by_tag(machine->config->devicelist, type, tag); - if (device == NULL) - fatalerror("devtag_get_info_ptr failed to find device: type=%s tag=%s\n", devtype_get_name(type), tag); - return device_get_info_ptr(device, state); -} - - /*------------------------------------------------- device_get_info_fct - return a function pointer state value from an allocated device @@ -812,22 +695,6 @@ genf *device_get_info_fct(const device_config *device, UINT32 state) } -genf *devtag_get_info_fct(running_machine *machine, device_type type, const char *tag, UINT32 state) -{ - const device_config *device; - - assert(machine != NULL); - assert(type != NULL); - assert(tag != NULL); - assert(state >= DEVINFO_INT_FIRST && state <= DEVINFO_INT_LAST); - - device = device_list_find_by_tag(machine->config->devicelist, type, tag); - if (device == NULL) - fatalerror("device_get_info_fct failed to find device: type=%s tag=%s\n", devtype_get_name(type), tag); - return device_get_info_fct(device, state); -} - - /*------------------------------------------------- device_get_info_string - return a string value from an allocated device @@ -848,22 +715,6 @@ const char *device_get_info_string(const device_config *device, UINT32 state) } -const char *devtag_get_info_string(running_machine *machine, device_type type, const char *tag, UINT32 state) -{ - const device_config *device; - - assert(machine != NULL); - assert(type != NULL); - assert(tag != NULL); - assert(state >= DEVINFO_INT_FIRST && state <= DEVINFO_INT_LAST); - - device = device_list_find_by_tag(machine->config->devicelist, type, tag); - if (device == NULL) - fatalerror("device_get_info_string failed to find device: type=%s tag=%s\n", devtype_get_name(type), tag); - return device_get_info_string(device, state); -} - - /*************************************************************************** DEVICE TYPE INFORMATION SETTERS @@ -889,6 +740,26 @@ INT64 devtype_get_info_int(device_type type, UINT32 state) } +/*------------------------------------------------- + devtype_get_info_int - return a function + pointer from a device type (does not need to + be allocated) +-------------------------------------------------*/ + +genf *devtype_get_info_fct(device_type type, UINT32 state) +{ + deviceinfo info; + + assert(type != NULL); + assert(state >= DEVINFO_FCT_FIRST && state <= DEVINFO_FCT_LAST); + + /* retrieve the value */ + info.f = 0; + (*type)(NULL, state, &info); + return info.f; +} + + /*------------------------------------------------- devtype_get_info_string - return a string value from a device type (does not need to be @@ -934,22 +805,6 @@ void device_set_info_int(const device_config *device, UINT32 state, INT64 data) } -void devtag_set_info_int(running_machine *machine, device_type type, const char *tag, UINT32 state, INT64 data) -{ - const device_config *device; - - assert(machine != NULL); - assert(type != NULL); - assert(tag != NULL); - assert(state >= DEVINFO_INT_FIRST && state <= DEVINFO_INT_LAST); - - device = device_list_find_by_tag(machine->config->devicelist, type, tag); - if (device == NULL) - fatalerror("devtag_set_info_int failed to find device: type=%s tag=%s\n", devtype_get_name(type), tag); - device_set_info_int(device, state, data); -} - - /*------------------------------------------------- device_set_info_ptr - set a pointer state value for an allocated device @@ -970,22 +825,6 @@ void device_set_info_ptr(const device_config *device, UINT32 state, void *data) } -void devtag_set_info_ptr(running_machine *machine, device_type type, const char *tag, UINT32 state, void *data) -{ - const device_config *device; - - assert(machine != NULL); - assert(type != NULL); - assert(tag != NULL); - assert(state >= DEVINFO_INT_FIRST && state <= DEVINFO_INT_LAST); - - device = device_list_find_by_tag(machine->config->devicelist, type, tag); - if (device == NULL) - fatalerror("devtag_set_info_ptr failed to find device: type=%s tag=%s\n", devtype_get_name(type), tag); - device_set_info_ptr(device, state, data); -} - - /*------------------------------------------------- device_set_info_fct - set a function pointer state value for an allocated device @@ -1004,19 +843,3 @@ void device_set_info_fct(const device_config *device, UINT32 state, genf *data) info.f = data; (*device->set_info)(device, state, &info); } - - -void devtag_set_info_fct(running_machine *machine, device_type type, const char *tag, UINT32 state, genf *data) -{ - const device_config *device; - - assert(machine != NULL); - assert(type != NULL); - assert(tag != NULL); - assert(state >= DEVINFO_INT_FIRST && state <= DEVINFO_INT_LAST); - - device = device_list_find_by_tag(machine->config->devicelist, type, tag); - if (device == NULL) - fatalerror("devtag_set_info_fct failed to find device: type=%s tag=%s\n", devtype_get_name(type), tag); - device_set_info_fct(device, state, data); -} diff --git a/src/emu/devintrf.h b/src/emu/devintrf.h index 544b7d54bbc..e4c644a9ed0 100644 --- a/src/emu/devintrf.h +++ b/src/emu/devintrf.h @@ -137,6 +137,45 @@ enum #define DEVICE_VALIDITY_CHECK_CALL(name) DEVICE_VALIDITY_CHECK(name)(driver, device) +/* shorthand for accessing devices by machine/type/tag */ +#define devtag_get_device(mach,type,tag) device_list_find_by_tag((mach)->config->devicelist, type, tag) + +#define devtag_reset(mach,type,tag) device_reset(devtag_get_device(mach, type, tag)) + +#define devtag_get_info_int(mach,type,tag,state) device_get_info_int(devtag_get_device(mach, type, tag), state) +#define devtag_get_info_ptr(mach,type,tag,state) device_get_info_ptr(devtag_get_device(mach, type, tag), state) +#define devtag_get_info_fct(mach,type,tag,state) device_get_info_fct(devtag_get_device(mach, type, tag), state) +#define devtag_get_info_string(mach,type,tag,state) device_get_info_string(devtag_get_device(mach, type, tag), state) + +#define devtag_set_info_int(mach,type,tag,state,data) device_set_info_int(devtag_get_device(mach, type, tag), state, data) +#define devtag_set_info_ptr(mach,type,tag,state,data) device_set_info_ptr(devtag_get_device(mach, type, tag), state, data) +#define devtag_set_info_fct(mach,type,tag,state,data) device_set_info_fct(devtag_get_device(mach, type, tag), state, data) + + +/* shorthand for getting standard data about device types */ +#define devtype_get_name(type) devtype_get_info_string(type, DEVINFO_STR_NAME) +#define devtype_get_family(type) devtype_get_info_string(type, DEVINFO_STR_FAMILY) +#define devtype_get_version(type) devtype_get_info_string(type, DEVINFO_STR_VERSION) +#define devtype_get_source_file(type) devtype_get_info_string(type, DEVINFO_STR_SOURCE_FILE) +#define devtype_get_credits(type) devtype_get_info_string(type, DEVINFO_STR_CREDITS) + + +/* shorthand for getting standard data about devices */ +#define device_get_name(dev) device_get_info_string(dev, DEVINFO_STR_NAME) +#define device_get_family(dev) device_get_info_string(dev, DEVINFO_STR_FAMILY) +#define device_get_version(dev) device_get_info_string(dev, DEVINFO_STR_VERSION) +#define device_get_source_file(dev) device_get_info_string(dev, DEVINFO_STR_SOURCE_FILE) +#define device_get_credits(dev) device_get_info_string(dev, DEVINFO_STR_CREDITS) + + +/* shorthand for getting standard data about devices by machine/type/tag */ +#define devtag_get_name(mach,type,tag) devtag_get_info_string(mach, type, tag, DEVINFO_STR_NAME) +#define devtag_get_family(mach,type,tag) devtag_get_info_string(mach, type, tag, DEVINFO_STR_FAMILY) +#define devtag_get_version(mach,type,tag) devtag_get_info_string(mach, type, tag, DEVINFO_STR_VERSION) +#define devtag_get_source_file(mach,type,tag) devtag_get_info_string(mach, type, tag, DEVINFO_STR_SOURCE_FILE) +#define devtag_get_credits(mach,type,tag) devtag_get_info_string(mach, type, tag, DEVINFO_STR_CREDITS) + + /*************************************************************************** TYPE DEFINITIONS @@ -184,20 +223,17 @@ union _deviceinfo struct _device_config { device_config * next; /* next device */ + device_config * typenext; /* next device of the same type */ device_type type; /* device type */ device_class class; /* device class */ device_set_info_func set_info; /* quick pointer to set_info callback */ - device_start_func start; /* quick pointer to start callback */ - device_stop_func stop; /* quick pointer to stop callback */ - device_reset_func reset; /* quick pointer to reset callback */ - device_nvram_func nvram; /* quick pointer to nvram callback */ const void * static_config; /* static device configuration */ void * inline_config; /* inline device configuration */ /* these fields are only valid if the device is live */ UINT8 started; /* TRUE if the start function has succeeded */ void * token; /* token if device is live */ - void * classtoken; /* class token if device is live */ + UINT32 tokenbytes; /* size of the token data allocated */ running_machine * machine; /* machine if device is live */ UINT8 * region; /* pointer to region with the device's tag, or NULL */ UINT32 regionbytes; /* size of the region, in bytes */ @@ -274,44 +310,30 @@ const device_config *device_list_class_find_by_index(const device_config *listhe /* ----- live device management ----- */ +/* "attach" a running_machine to its list of devices */ +void device_list_attach_machine(running_machine *machine); + /* start the configured list of devices for a machine */ void device_list_start(running_machine *machine); /* reset a device based on an allocated device_config */ void device_reset(const device_config *device); -void devtag_reset(running_machine *machine, device_type type, const char *tag); /* ----- device information getters ----- */ -/* return the device associated with a tag */ -const device_config *devtag_get_device(running_machine *machine, device_type type, const char *tag); - -/* return the token associated with an allocated device */ -void *devtag_get_token(running_machine *machine, device_type type, const char *tag); - -/* return a pointer to the static configuration for a device based on type and tag */ -const void *devtag_get_static_config(running_machine *machine, device_type type, const char *tag); - -/* return a pointer to the inline configuration for a device based on type and tag */ -const void *devtag_get_inline_config(running_machine *machine, device_type type, const char *tag); - /* return an integer state value from an allocated device */ INT64 device_get_info_int(const device_config *device, UINT32 state); -INT64 devtag_get_info_int(running_machine *machine, device_type type, const char *tag, UINT32 state); /* return a pointer state value from an allocated device */ void *device_get_info_ptr(const device_config *device, UINT32 state); -void *devtag_get_info_ptr(running_machine *machine, device_type type, const char *tag, UINT32 state); /* return a function pointer state value from an allocated device */ genf *device_get_info_fct(const device_config *device, UINT32 state); -genf *devtag_get_info_fct(running_machine *machine, device_type type, const char *tag, UINT32 state); /* return a string value from an allocated device */ const char *device_get_info_string(const device_config *device, UINT32 state); -const char *devtag_get_info_string(running_machine *machine, device_type type, const char *tag, UINT32 state); @@ -320,6 +342,9 @@ const char *devtag_get_info_string(running_machine *machine, device_type type, c /* return an integer value from a device type (does not need to be allocated) */ INT64 devtype_get_info_int(device_type type, UINT32 state); +/* return a function pointer from a device type (does not need to be allocated) */ +genf *devtype_get_info_fct(device_type type, UINT32 state); + /* return a string value from a device type (does not need to be allocated) */ const char *devtype_get_info_string(device_type type, UINT32 state); @@ -329,35 +354,12 @@ const char *devtype_get_info_string(device_type type, UINT32 state); /* set an integer state value for an allocated device */ void device_set_info_int(const device_config *device, UINT32 state, INT64 data); -void devtag_set_info_int(running_machine *machine, device_type type, const char *tag, UINT32 state, INT64 data); /* set a pointer state value for an allocated device */ void device_set_info_ptr(const device_config *device, UINT32 state, void *data); -void devtag_set_info_ptr(running_machine *machine, device_type type, const char *tag, UINT32 state, void *data); /* set a function pointer state value for an allocated device */ void device_set_info_fct(const device_config *device, UINT32 state, genf *data); -void devtag_set_info_fct(running_machine *machine, device_type type, const char *tag, UINT32 state, genf *data); - - - -/*************************************************************************** - INLINE FUNCTIONS -***************************************************************************/ - -/* return common strings based on device instances */ -INLINE const char *device_get_name(const device_config *device) { return device_get_info_string(device, DEVINFO_STR_NAME); } -INLINE const char *device_get_family(const device_config *device) { return device_get_info_string(device, DEVINFO_STR_FAMILY); } -INLINE const char *device_get_version(const device_config *device) { return device_get_info_string(device, DEVINFO_STR_VERSION); } -INLINE const char *device_get_source_file(const device_config *device) { return device_get_info_string(device, DEVINFO_STR_SOURCE_FILE); } -INLINE const char *device_get_credits(const device_config *device) { return device_get_info_string(device, DEVINFO_STR_CREDITS); } - -/* return common strings based on device types */ -INLINE const char *devtype_get_name(device_type devtype) { return devtype_get_info_string(devtype, DEVINFO_STR_NAME); } -INLINE const char *devtype_get_family(device_type devtype) { return devtype_get_info_string(devtype, DEVINFO_STR_FAMILY); } -INLINE const char *devtype_get_version(device_type devtype) { return devtype_get_info_string(devtype, DEVINFO_STR_VERSION); } -INLINE const char *devtype_get_source_file(device_type devtype) { return devtype_get_info_string(devtype, DEVINFO_STR_SOURCE_FILE); } -INLINE const char *devtype_get_credits(device_type devtype) { return devtype_get_info_string(devtype, DEVINFO_STR_CREDITS); } #endif /* __DEVINTRF_H__ */ diff --git a/src/emu/info.c b/src/emu/info.c index 076cf374bcb..624416810ba 100644 --- a/src/emu/info.c +++ b/src/emu/info.c @@ -569,19 +569,19 @@ static void print_game_sample(FILE *out, const game_driver *game, const machine_ static void print_game_chips(FILE *out, const game_driver *game, const machine_config *config) { + const device_config *device; int chipnum; /* iterate over CPUs */ - for (chipnum = 0; chipnum < ARRAY_LENGTH(config->cpu); chipnum++) - if (config->cpu[chipnum].type != CPU_DUMMY) - { - fprintf(out, "\t\tcpu[chipnum].tag)); - fprintf(out, " name=\"%s\"", xml_normalize_string(cputype_get_name(config->cpu[chipnum].type))); - fprintf(out, " clock=\"%d\"", config->cpu[chipnum].clock); - fprintf(out, "/>\n"); - } + for (device = cpu_first(config); device != NULL; device = cpu_next(device)) + { + fprintf(out, "\t\ttag)); + fprintf(out, " name=\"%s\"", xml_normalize_string(device_get_name(device))); + fprintf(out, " clock=\"%d\"", ((const cpu_config *)device->inline_config)->clock); + fprintf(out, "/>\n"); + } /* iterate over sound chips */ for (chipnum = 0; chipnum < ARRAY_LENGTH(config->sound); chipnum++) diff --git a/src/emu/machine/8237dma.c b/src/emu/machine/8237dma.c index 667065c709f..2a56252635f 100644 --- a/src/emu/machine/8237dma.c +++ b/src/emu/machine/8237dma.c @@ -174,9 +174,9 @@ static void dma8237_update_status(const device_config *device) } /* set the halt line */ - if (dma8237->intf && dma8237->intf->cpunum >= 0) + if (dma8237->intf && dma8237->intf->cputag != NULL) { - cpu_set_input_line(device->machine->cpu[dma8237->intf->cpunum], INPUT_LINE_HALT, + cputag_set_input_line(device->machine, dma8237->intf->cputag, INPUT_LINE_HALT, pending_transfer ? ASSERT_LINE : CLEAR_LINE); } diff --git a/src/emu/machine/8237dma.h b/src/emu/machine/8237dma.h index d0883d205b8..82918b729c7 100644 --- a/src/emu/machine/8237dma.h +++ b/src/emu/machine/8237dma.h @@ -24,7 +24,7 @@ typedef void (*dma8237_out_eop_func)(const device_config *device, int state); struct dma8237_interface { /* CPU to halt when DMA is active */ - int cpunum; + const char *cputag; /* speed of DMA accesses (per byte) */ double bus_speed; diff --git a/src/emu/machine/8257dma.c b/src/emu/machine/8257dma.c index bd5463052c5..a838ed73102 100644 --- a/src/emu/machine/8257dma.c +++ b/src/emu/machine/8257dma.c @@ -218,9 +218,9 @@ static void dma8257_update_status(const device_config *device) } /* set the halt line */ - if (dma8257->intf && dma8257->intf->cpunum >= 0) + if (dma8257->intf && dma8257->intf->cputag != NULL) { - cpu_set_input_line(device->machine->cpu[dma8257->intf->cpunum], INPUT_LINE_HALT, + cputag_set_input_line(device->machine, dma8257->intf->cputag, INPUT_LINE_HALT, pending_transfer ? ASSERT_LINE : CLEAR_LINE); } diff --git a/src/emu/machine/8257dma.h b/src/emu/machine/8257dma.h index e311c9e6403..25959b275e4 100644 --- a/src/emu/machine/8257dma.h +++ b/src/emu/machine/8257dma.h @@ -22,7 +22,7 @@ typedef struct _dma8257_interface dma8257_interface; struct _dma8257_interface { /* CPU to halt when DMA is active */ - int cpunum; + const char *cputag; /* clock */ int clockhz; diff --git a/src/emu/machine/generic.c b/src/emu/machine/generic.c index d3944fb5833..a502e150555 100644 --- a/src/emu/machine/generic.c +++ b/src/emu/machine/generic.c @@ -272,7 +272,7 @@ mame_file *nvram_fopen(running_machine *machine, UINT32 openflags) void nvram_load(running_machine *machine) { mame_file *nvram_file = NULL; - device_config *device; + const device_config *device; if (machine->config->nvram_handler != NULL) { @@ -280,23 +280,19 @@ void nvram_load(running_machine *machine) (*machine->config->nvram_handler)(machine, nvram_file, 0); } - for (device = (device_config *)machine->config->devicelist; device != NULL; device = device->next) + for (device = machine->config->devicelist; device != NULL; device = device->next) { - if (device->nvram != NULL) + device_nvram_func nvram = (device_nvram_func)device_get_info_fct(device, DEVINFO_FCT_NVRAM); + if (nvram != NULL) { if (nvram_file == NULL) - { nvram_file = nvram_fopen(machine, OPEN_FLAG_READ); - } - - (*device->nvram)(device, nvram_file, 0); + (*nvram)(device, nvram_file, 0); } } if (nvram_file != NULL) - { mame_fclose(nvram_file); - } } @@ -307,7 +303,7 @@ void nvram_load(running_machine *machine) void nvram_save(running_machine *machine) { mame_file *nvram_file = NULL; - device_config *device; + const device_config *device; if (machine->config->nvram_handler != NULL) { @@ -315,23 +311,19 @@ void nvram_save(running_machine *machine) (*machine->config->nvram_handler)(machine, nvram_file, 1); } - for (device = (device_config *)machine->config->devicelist; device != NULL; device = device->next) + for (device = machine->config->devicelist; device != NULL; device = device->next) { - if (device->nvram != NULL) + device_nvram_func nvram = (device_nvram_func)device_get_info_fct(device, DEVINFO_FCT_NVRAM); + if (nvram != NULL) { if (nvram_file == NULL) - { nvram_file = nvram_fopen(machine, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); - } - - (*device->nvram)(device, nvram_file, 1); + (*nvram)(device, nvram_file, 1); } } if (nvram_file != NULL) - { mame_fclose(nvram_file); - } } @@ -579,14 +571,14 @@ static void interrupt_reset(running_machine *machine) static TIMER_CALLBACK( clear_all_lines ) { - int cpunum = param; - int inputcount = cpu_get_input_lines(machine->cpu[cpunum]); + const device_config *device = ptr; + int inputcount = cpu_get_input_lines(device); int line; /* clear NMI and all inputs */ - cpu_set_input_line(machine->cpu[cpunum], INPUT_LINE_NMI, CLEAR_LINE); + cpu_set_input_line(device, INPUT_LINE_NMI, CLEAR_LINE); for (line = 0; line < inputcount; line++) - cpu_set_input_line(machine->cpu[cpunum], line, CLEAR_LINE); + cpu_set_input_line(device, line, CLEAR_LINE); } @@ -637,16 +629,18 @@ void generic_pulse_irq_line_and_vector(const device_config *device, int irqline, disable value for global interrupts -------------------------------------------------*/ -void cpu_interrupt_enable(int cpunum, int enabled) +void cpu_interrupt_enable(const device_config *device, int enabled) { - assert_always(cpunum >= 0 && cpunum < ARRAY_LENGTH(Machine->cpu) && Machine->cpu[cpunum] != NULL, "cpu_interrupt_enable() called for invalid cpu num!"); + int cpunum = cpu_get_index(device); + + assert_always(device != NULL, "cpu_interrupt_enable() called for invalid cpu!"); /* set the new state */ interrupt_enable[cpunum] = enabled; /* make sure there are no queued interrupts */ if (enabled == 0) - timer_call_after_resynch(Machine, NULL, cpunum, clear_all_lines); + timer_call_after_resynch(device->machine, (void *)device, 0, clear_all_lines); } @@ -657,7 +651,7 @@ void cpu_interrupt_enable(int cpunum, int enabled) WRITE8_HANDLER( interrupt_enable_w ) { - cpu_interrupt_enable(cpu_get_index(space->cpu), data); + cpu_interrupt_enable(space->cpu, data); } diff --git a/src/emu/machine/generic.h b/src/emu/machine/generic.h index edf1fd352e6..60de3df8596 100644 --- a/src/emu/machine/generic.h +++ b/src/emu/machine/generic.h @@ -121,7 +121,7 @@ void set_led_status(int num, int value); void generic_pulse_irq_line(const device_config *device, int irqline); void generic_pulse_irq_line_and_vector(const device_config *device, int irqline, int vector); -void cpu_interrupt_enable(int cpu, int enabled); +void cpu_interrupt_enable(const device_config *device, int enabled); READ8_HANDLER( interrupt_enable_r ); WRITE8_HANDLER( interrupt_enable_w ); diff --git a/src/emu/machine/z80dma.c b/src/emu/machine/z80dma.c index be6d5aee3c2..ad208a2ce6c 100644 --- a/src/emu/machine/z80dma.c +++ b/src/emu/machine/z80dma.c @@ -256,10 +256,10 @@ static void z80dma_update_status(const device_config *device) } /* set the halt line */ - if (z80dma->intf && z80dma->intf->cpunum >= 0) + if (z80dma->intf && z80dma->intf->cputag != NULL) { //FIXME: Synchronization is done by BUSREQ! - cpu_set_input_line(device->machine->cpu[z80dma->intf->cpunum], INPUT_LINE_HALT, + cputag_set_input_line(device->machine, z80dma->intf->cputag, INPUT_LINE_HALT, pending_transfer ? ASSERT_LINE : CLEAR_LINE); } } diff --git a/src/emu/machine/z80dma.h b/src/emu/machine/z80dma.h index 17ede2503a5..4966a9624b2 100644 --- a/src/emu/machine/z80dma.h +++ b/src/emu/machine/z80dma.h @@ -13,7 +13,7 @@ typedef struct _z80dma_interface z80dma_interface; struct _z80dma_interface { /* CPU to halt when DMA is active */ - int cpunum; + const char *cputag; /* clock */ int clockhz; diff --git a/src/emu/mame.c b/src/emu/mame.c index 3e3fc40813d..4d3e0447117 100644 --- a/src/emu/mame.c +++ b/src/emu/mame.c @@ -216,7 +216,6 @@ extern int mame_validitychecks(const game_driver *driver); static int parse_ini_file(core_options *options, const char *name); static running_machine *create_machine(const game_driver *driver); -static void prepare_machine(running_machine *machine); static void destroy_machine(running_machine *machine); static void init_machine(running_machine *machine); static TIMER_CALLBACK( soft_reset ); @@ -241,11 +240,10 @@ static void logfile_callback(running_machine *machine, const char *buffer); INLINE void eat_all_cpu_cycles(running_machine *machine) { - int cpunum; + const device_config *cpu; - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) - cpu_eat_cycles(machine->cpu[cpunum], 1000000000); + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + cpu_eat_cycles(cpu, 1000000000); } @@ -301,7 +299,6 @@ int mame_execute(core_options *options) /* create the machine structure and driver */ machine = create_machine(driver); - prepare_machine(machine); mame = machine->mame_data; /* start in the "pre-init phase" */ @@ -1404,18 +1401,28 @@ static running_machine *create_machine(const game_driver *driver) machine->basename = mame_strdup(driver->name); machine->config = machine_config_alloc(driver->machine_config); - /* temporary: create fake CPU devices */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->config->cpu[cpunum].type != CPU_DUMMY) - machine->cpu[cpunum] = cpuexec_create_cpu_device(&machine->config->cpu[cpunum]); - /* allocate the driver data */ if (machine->config->driver_data_size != 0) { machine->driver_data = malloc(machine->config->driver_data_size); if (machine->driver_data == NULL) goto error; + memset(machine->driver_data, 0, machine->config->driver_data_size); } + + /* find devices */ + machine->cpu[0] = cpu_first(machine->config); + for (cpunum = 1; cpunum < ARRAY_LENGTH(machine->cpu) && machine->cpu[cpunum - 1] != NULL; cpunum++) + machine->cpu[cpunum] = machine->cpu[cpunum - 1]->typenext; + machine->primary_screen = video_screen_first(machine->config); + + /* attach this machine to tall the devices in the configuration */ + device_list_attach_machine(machine); + + /* fetch core options */ + machine->sample_rate = options_get_int(mame_options(), OPTION_SAMPLERATE); + machine->debug_flags = options_get_bool(mame_options(), OPTION_DEBUG) ? (DEBUG_FLAG_ENABLED | DEBUG_FLAG_CALL_HOOK) : 0; + return machine; error: @@ -1431,58 +1438,14 @@ error: } -/*------------------------------------------------- - prepare_machine - reset the state of the - machine object --------------------------------------------------*/ - -static void prepare_machine(running_machine *machine) -{ - /* reset most portions of the machine */ - - /* graphics layout */ - memset(machine->gfx, 0, sizeof(machine->gfx)); - - /* palette-related information */ - machine->pens = NULL; - machine->shadow_table = NULL; - - /* audio-related information */ - machine->sample_rate = options_get_int(mame_options(), OPTION_SAMPLERATE); - - /* input-related information */ - machine->portconfig = NULL; - - /* debugger-related information */ - machine->debug_flags = options_get_bool(mame_options(), OPTION_DEBUG) ? (DEBUG_FLAG_ENABLED | DEBUG_FLAG_CALL_HOOK) : 0; - - /* reset the global MAME data and clear the other privates */ - memset(machine->mame_data, 0, sizeof(*machine->mame_data)); - machine->palette_data = NULL; - machine->streams_data = NULL; - - /* reset the driver data */ - if (machine->config->driver_data_size != 0) - memset(machine->driver_data, 0, machine->config->driver_data_size); -} - - - /*------------------------------------------------- destroy_machine - free the machine data -------------------------------------------------*/ static void destroy_machine(running_machine *machine) { - int cpunum; - assert(machine == Machine); - /* temporary: free the fake CPU devices */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) - free((void *)machine->cpu[cpunum]); - if (machine->driver_data != NULL) free(machine->driver_data); if (machine->config != NULL) diff --git a/src/emu/mconfig.c b/src/emu/mconfig.c index 91898784517..92b38a9f515 100644 --- a/src/emu/mconfig.c +++ b/src/emu/mconfig.c @@ -58,16 +58,13 @@ machine_config *machine_config_alloc(const machine_config_token *tokens) void machine_config_free(machine_config *config) { - int cpunum, soundnum; + int soundnum; /* release the device list */ while (config->devicelist != NULL) device_list_remove(&config->devicelist, config->devicelist->type, config->devicelist->tag); /* release the strings */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(config->cputag); cpunum++) - if (config->cputag[cpunum] != NULL) - astring_free(config->cputag[cpunum]); for (soundnum = 0; soundnum < ARRAY_LENGTH(config->soundtag); soundnum++) if (config->soundtag[soundnum] != NULL) astring_free(config->soundtag[soundnum]); @@ -77,75 +74,6 @@ void machine_config_free(machine_config *config) } -/*------------------------------------------------- - cpu_add - add a CPU during machine driver - expansion --------------------------------------------------*/ - -static cpu_config *cpu_add(machine_config *machine, const char *tag, cpu_type type, int cpuclock) -{ - int cpunum; - - for (cpunum = 0; cpunum < MAX_CPU; cpunum++) - if (machine->cpu[cpunum].type == CPU_DUMMY) - { - if (machine->cputag[cpunum] == NULL) - machine->cputag[cpunum] = astring_alloc(); - astring_cpyc(machine->cputag[cpunum], tag); - machine->cpu[cpunum].tag = astring_c(machine->cputag[cpunum]); - machine->cpu[cpunum].type = type; - machine->cpu[cpunum].clock = cpuclock; - return &machine->cpu[cpunum]; - } - - fatalerror("Out of CPU's!\n"); - return NULL; -} - - -/*------------------------------------------------- - cpu_find - find a tagged CPU during machine - driver expansion --------------------------------------------------*/ - -static cpu_config *cpu_find(machine_config *machine, const char *tag) -{ - int cpunum; - - for (cpunum = 0; cpunum < MAX_CPU; cpunum++) - if (machine->cpu[cpunum].tag && strcmp(machine->cpu[cpunum].tag, tag) == 0) - return &machine->cpu[cpunum]; - - fatalerror("Can't find CPU '%s'!\n", tag); - return NULL; -} - - -/*------------------------------------------------- - cpu_remove - remove a tagged CPU during - machine driver expansion --------------------------------------------------*/ - -static void cpu_remove(machine_config *machine, const char *tag) -{ - int cpunum; - - for (cpunum = 0; cpunum < MAX_CPU; cpunum++) - if (machine->cpu[cpunum].tag && strcmp(machine->cpu[cpunum].tag, tag) == 0) - { - if (machine->cputag[cpunum] != NULL) - astring_free(machine->cputag[cpunum]); - memmove(&machine->cpu[cpunum], &machine->cpu[cpunum + 1], sizeof(machine->cpu[0]) * (MAX_CPU - cpunum - 1)); - memmove(&machine->cputag[cpunum], &machine->cputag[cpunum + 1], sizeof(machine->cputag[0]) * (MAX_CPU - cpunum - 1)); - memset(&machine->cpu[MAX_CPU - 1], 0, sizeof(machine->cpu[0])); - memset(&machine->cputag[MAX_CPU - 1], 0, sizeof(machine->cputag[0])); - return; - } - - fatalerror("Can't find CPU '%s'!\n", tag); -} - - /*------------------------------------------------- sound_add - add a sound system during machine driver expansion @@ -228,7 +156,6 @@ static void machine_config_detokenize(machine_config *config, const machine_conf astring *tempstring = astring_alloc(); device_config *device = NULL; sound_config *sound = NULL; - cpu_config *cpu = NULL; /* loop over tokens until we hit the end */ while (entrytype != MCONFIG_TOKEN_END) @@ -331,90 +258,6 @@ static void machine_config_detokenize(machine_config *config, const machine_conf break; - /* add/modify/remove/replace CPUs */ - case MCONFIG_TOKEN_CPU_ADD: - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT64_UNPACK3(tokens, entrytype, 8, type, 24, clock, 32); - tag = TOKEN_GET_STRING(tokens); - cpu = cpu_add(config, device_build_tag(tempstring, tagprefix, tag), type, clock); - break; - - case MCONFIG_TOKEN_CPU_MODIFY: - tag = TOKEN_GET_STRING(tokens); - cpu = cpu_find(config, device_build_tag(tempstring, tagprefix, tag)); - break; - - case MCONFIG_TOKEN_CPU_REMOVE: - tag = TOKEN_GET_STRING(tokens); - cpu_remove(config, device_build_tag(tempstring, tagprefix, tag)); - cpu = NULL; - break; - - case MCONFIG_TOKEN_CPU_REPLACE: - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT64_UNPACK3(tokens, entrytype, 8, type, 24, clock, 32); - tag = TOKEN_GET_STRING(tokens); - cpu = cpu_find(config, device_build_tag(tempstring, tagprefix, tag)); - if (cpu == NULL) - fatalerror("Unable to find CPU: tag=%s\n", astring_c(tempstring)); - cpu->type = type; - cpu->clock = clock; - break; - - /* CPU parameters */ - case MCONFIG_TOKEN_cpu_get_flags: - assert(cpu != NULL); - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, cpu->flags, 24); - break; - - case MCONFIG_TOKEN_CPU_CONFIG: - assert(cpu != NULL); - cpu->reset_param = TOKEN_GET_PTR(tokens, voidptr); - break; - - case MCONFIG_TOKEN_CPU_PROGRAM_MAP: - assert(cpu != NULL); - cpu->address_map[ADDRESS_SPACE_PROGRAM][0] = TOKEN_GET_PTR(tokens, addrmap); - cpu->address_map[ADDRESS_SPACE_PROGRAM][1] = TOKEN_GET_PTR(tokens, addrmap); - break; - - case MCONFIG_TOKEN_CPU_DATA_MAP: - assert(cpu != NULL); - cpu->address_map[ADDRESS_SPACE_DATA][0] = TOKEN_GET_PTR(tokens, addrmap); - cpu->address_map[ADDRESS_SPACE_DATA][1] = TOKEN_GET_PTR(tokens, addrmap); - break; - - case MCONFIG_TOKEN_CPU_IO_MAP: - assert(cpu != NULL); - cpu->address_map[ADDRESS_SPACE_IO][0] = TOKEN_GET_PTR(tokens, addrmap); - cpu->address_map[ADDRESS_SPACE_IO][1] = TOKEN_GET_PTR(tokens, addrmap); - break; - - case MCONFIG_TOKEN_CPU_VBLANK_INT: - assert(cpu != NULL); - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT32_UNPACK1(tokens, entrytype, 8); - cpu->vblank_interrupt_screen = TOKEN_GET_STRING(tokens); - cpu->vblank_interrupt = TOKEN_GET_PTR(tokens, interrupt); - cpu->vblank_interrupts_per_frame = 1; - break; - - case MCONFIG_TOKEN_CPU_VBLANK_INT_HACK: - assert(cpu != NULL); - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, cpu->vblank_interrupts_per_frame, 24); - cpu->vblank_interrupt = TOKEN_GET_PTR(tokens, interrupt); - break; - - case MCONFIG_TOKEN_CPU_PERIODIC_INT: - assert(cpu != NULL); - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, data32, 24); - cpu->timed_interrupt_period = HZ_TO_ATTOSECONDS(data32); - cpu->timed_interrupt = TOKEN_GET_PTR(tokens, interrupt); - break; - /* core parameters */ case MCONFIG_TOKEN_DRIVER_DATA: TOKEN_UNGET_UINT32(tokens); diff --git a/src/emu/mconfig.h b/src/emu/mconfig.h index 016d14e5519..54fc55e908c 100644 --- a/src/emu/mconfig.h +++ b/src/emu/mconfig.h @@ -43,19 +43,6 @@ enum MCONFIG_TOKEN_DEVICE_CONFIG_DATAFP32, MCONFIG_TOKEN_DEVICE_CONFIG_DATAFP64, - MCONFIG_TOKEN_CPU_ADD, - MCONFIG_TOKEN_CPU_MODIFY, - MCONFIG_TOKEN_CPU_REMOVE, - MCONFIG_TOKEN_CPU_REPLACE, - MCONFIG_TOKEN_cpu_get_flags, - MCONFIG_TOKEN_CPU_CONFIG, - MCONFIG_TOKEN_CPU_PROGRAM_MAP, - MCONFIG_TOKEN_CPU_DATA_MAP, - MCONFIG_TOKEN_CPU_IO_MAP, - MCONFIG_TOKEN_CPU_VBLANK_INT, - MCONFIG_TOKEN_CPU_VBLANK_INT_HACK, - MCONFIG_TOKEN_CPU_PERIODIC_INT, - MCONFIG_TOKEN_DRIVER_DATA, MCONFIG_TOKEN_INTERLEAVE, MCONFIG_TOKEN_WATCHDOG_VBLANK, @@ -124,8 +111,6 @@ struct _machine_config { UINT32 driver_data_size; /* amount of memory needed for driver_data */ - cpu_config cpu[MAX_CPU]; /* array of CPUs in the system */ - astring * cputag[MAX_CPU]; /* allocated strings for each CPU tag */ UINT32 cpu_slices_per_frame; /* number of times to interleave execution per frame */ INT32 watchdog_vblank_count; /* number of VBLANKs until the watchdog kills us */ attotime watchdog_time; /* length of time until the watchdog kills us */ @@ -171,7 +156,6 @@ union _machine_config_token const gfx_decode_entry *gfxdecode; const addrmap_token *addrmap; device_type devtype; - void (*interrupt)(const device_config *device); driver_init_func driver_init; nvram_handler_func nvram_handler; memcard_handler_func memcard_handler; @@ -278,57 +262,6 @@ union _machine_config_token #endif -/* add/modify/remove/replace CPUs */ -#define MDRV_CPU_ADD(_tag, _type, _clock) \ - TOKEN_UINT64_PACK3(MCONFIG_TOKEN_CPU_ADD, 8, CPU_##_type, 24, _clock, 32), \ - TOKEN_STRING(_tag), - -#define MDRV_CPU_MODIFY(_tag) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_CPU_MODIFY, 8), \ - TOKEN_STRING(_tag), - -#define MDRV_CPU_REMOVE(_tag) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_CPU_REMOVE, 8), \ - TOKEN_STRING(_tag), - -#define MDRV_CPU_REPLACE(_tag, _type, _clock) \ - TOKEN_UINT64_PACK3(MCONFIG_TOKEN_CPU_REPLACE, 8, CPU_##_type, 24, _clock, 32), \ - TOKEN_STRING(_tag), - - -/* CPU parameters */ -#define MDRV_CPU_FLAGS(_flags) \ - TOKEN_UINT32_PACK2(MCONFIG_TOKEN_cpu_get_flags, 8, _flags, 24), - -#define MDRV_CPU_CONFIG(_config) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_CPU_CONFIG, 8), \ - TOKEN_PTR(voidptr, &(_config)), - -#define MDRV_CPU_PROGRAM_MAP(_map1, _map2) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_CPU_PROGRAM_MAP, 8), \ - TOKEN_PTR(voidptr, ADDRESS_MAP_NAME(_map1)), \ - TOKEN_PTR(voidptr, ADDRESS_MAP_NAME(_map2)), \ - -#define MDRV_CPU_DATA_MAP(_map1, _map2) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_CPU_DATA_MAP, 8), \ - TOKEN_PTR(voidptr, ADDRESS_MAP_NAME(_map1)), \ - TOKEN_PTR(voidptr, ADDRESS_MAP_NAME(_map2)), \ - -#define MDRV_CPU_IO_MAP(_map1, _map2) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_CPU_IO_MAP, 8), \ - TOKEN_PTR(voidptr, ADDRESS_MAP_NAME(_map1)), \ - TOKEN_PTR(voidptr, ADDRESS_MAP_NAME(_map2)), \ - -#define MDRV_CPU_VBLANK_INT(_tag, _func) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_CPU_VBLANK_INT, 8), \ - TOKEN_STRING(_tag), \ - TOKEN_PTR(interrupt, _func), - -#define MDRV_CPU_PERIODIC_INT(_func, _rate) \ - TOKEN_UINT32_PACK2(MCONFIG_TOKEN_CPU_PERIODIC_INT, 8, _rate, 24), \ - TOKEN_PTR(interrupt, _func), - - /* core parameters */ #define MDRV_DRIVER_DATA(_struct) \ TOKEN_UINT32_PACK2(MCONFIG_TOKEN_DRIVER_DATA, 8, sizeof(_struct), 24), diff --git a/src/emu/memory.c b/src/emu/memory.c index cc85c7f42b2..afa17c72b39 100644 --- a/src/emu/memory.c +++ b/src/emu/memory.c @@ -750,25 +750,25 @@ const address_space *memory_find_address_space(const device_config *cpu, int spa address map for a CPU's address space -------------------------------------------------*/ -address_map *address_map_alloc(const machine_config *config, const game_driver *driver, int cpunum, int spacenum) +address_map *address_map_alloc(const device_config *device, const game_driver *driver, int spacenum) { - const char *cputag = config->cpu[cpunum].tag; - int cputype = config->cpu[cpunum].type; - const addrmap_token *internal_map = (const addrmap_token *)cputype_get_info_ptr(cputype, CPUINFO_PTR_INTERNAL_MEMORY_MAP + spacenum); + const cpu_config *cpuconfig = device->inline_config; + const addrmap_token *internal_map; address_map *map; map = malloc_or_die(sizeof(*map)); memset(map, 0, sizeof(*map)); /* append the internal CPU map (first so it takes priority) */ + internal_map = (const addrmap_token *)cputype_get_info_ptr(cpuconfig->type, CPUINFO_PTR_INTERNAL_MEMORY_MAP + spacenum); if (internal_map != NULL) - map_detokenize(map, driver, cputag, internal_map); + map_detokenize(map, driver, device->tag, internal_map); /* construct the standard map */ - if (config->cpu[cpunum].address_map[spacenum][0] != NULL) - map_detokenize(map, driver, cputag, config->cpu[cpunum].address_map[spacenum][0]); - if (config->cpu[cpunum].address_map[spacenum][1] != NULL) - map_detokenize(map, driver, cputag, config->cpu[cpunum].address_map[spacenum][1]); + if (cpuconfig->address_map[spacenum] != NULL) + map_detokenize(map, driver, device->tag, cpuconfig->address_map[spacenum]); + if (cpuconfig->address_map2[spacenum] != NULL) + map_detokenize(map, driver, device->tag, cpuconfig->address_map2[spacenum]); return map; } @@ -1328,7 +1328,7 @@ UINT64 *_memory_install_device_handler64(const address_space *space, const devic int memory_address_physical(const address_space *space, int intention, offs_t *address) { - cpu_class_header *classheader = space->cpu->classtoken; + cpu_class_header *classheader = cpu_get_class_header(space->cpu); if (classheader->translate != NULL) return (*classheader->translate)(space->cpu, space->spacenum, intention, address); else @@ -1474,115 +1474,109 @@ void memory_dump(running_machine *machine, FILE *file) static void memory_init_spaces(running_machine *machine) { - const machine_config *config = machine->config; memory_private *memdata = machine->memory_data; address_space **nextptr = (address_space **)&memdata->spacelist; - int cpunum, spacenum; + const device_config *device; + int spacenum; /* create a global watchpoint-filled table */ memdata->wptable = auto_malloc(1 << LEVEL1_BITS); memset(memdata->wptable, STATIC_WATCHPOINT, 1 << LEVEL1_BITS); /* loop over CPUs */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) - { - cpu_type cputype = config->cpu[cpunum].type; + for (device = machine->cpu[0]; device != NULL; device = device->typenext) + for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) + if (cpu_get_addrbus_width(device, spacenum) > 0) + { + address_space *space = malloc_or_die(sizeof(*space)); + int logbits = cpu_get_logaddr_width(device, spacenum); + int ashift = cpu_get_addrbus_shift(device, spacenum); + int abits = cpu_get_addrbus_width(device, spacenum); + int dbits = cpu_get_databus_width(device, spacenum); + int endianness = cpu_get_endianness(device); + int accessorindex = (dbits == 8) ? 0 : (dbits == 16) ? 1 : (dbits == 32) ? 2 : 3; + int entrynum; - /* initialize each address space with an actual address bus */ - for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) - if (cputype_get_addrbus_width(cputype, spacenum) > 0) + /* if logbits is 0, revert to abits */ + if (logbits == 0) + logbits = abits; + + /* determine the address and data bits */ + memset(space, 0, sizeof(*space)); + space->machine = machine; + space->cpu = device; + space->name = address_space_names[spacenum]; + space->accessors = memory_accessors[accessorindex][(endianness == ENDIANNESS_LITTLE) ? 0 : 1]; + space->addrmask = 0xffffffffUL >> (32 - abits); + space->bytemask = (ashift < 0) ? ((space->addrmask << -ashift) | ((1 << -ashift) - 1)) : (space->addrmask >> ashift); + space->logaddrmask = 0xffffffffUL >> (32 - logbits); + space->logbytemask = (ashift < 0) ? ((space->logaddrmask << -ashift) | ((1 << -ashift) - 1)) : (space->logaddrmask >> ashift); + space->spacenum = spacenum; + space->endianness = endianness; + space->ashift = ashift; + space->pageshift = cpu_get_page_shift(device, spacenum); + space->abits = abits; + space->dbits = dbits; + space->addrchars = (abits + 3) / 4; + space->logaddrchars = (logbits + 3) / 4; + space->log_unmap = TRUE; + + /* allocate subtable information; we malloc this manually because it will be realloc'ed */ + space->read.subtable = auto_malloc(sizeof(*space->read.subtable) * SUBTABLE_COUNT); + memset(space->read.subtable, 0, sizeof(*space->read.subtable) * SUBTABLE_COUNT); + space->write.subtable = auto_malloc(sizeof(*space->write.subtable) * SUBTABLE_COUNT); + memset(space->write.subtable, 0, sizeof(*space->write.subtable) * SUBTABLE_COUNT); + + /* allocate the handler table */ + space->read.handlers[0] = auto_malloc(sizeof(*space->read.handlers[0]) * ARRAY_LENGTH(space->read.handlers)); + memset(space->read.handlers[0], 0, sizeof(*space->read.handlers[0]) * ARRAY_LENGTH(space->read.handlers)); + space->write.handlers[0] = auto_malloc(sizeof(*space->write.handlers[0]) * ARRAY_LENGTH(space->write.handlers)); + memset(space->write.handlers[0], 0, sizeof(*space->write.handlers[0]) * ARRAY_LENGTH(space->write.handlers)); + for (entrynum = 1; entrynum < ARRAY_LENGTH(space->read.handlers); entrynum++) { - address_space *space = malloc_or_die(sizeof(*space)); - int logbits = cputype_get_logaddr_width(cputype, spacenum); - int ashift = cputype_get_addrbus_shift(cputype, spacenum); - int abits = cputype_get_addrbus_width(cputype, spacenum); - int dbits = cputype_get_databus_width(cputype, spacenum); - int endianness = cputype_get_endianness(cputype); - int accessorindex = (dbits == 8) ? 0 : (dbits == 16) ? 1 : (dbits == 32) ? 2 : 3; - int entrynum; - - /* if logbits is 0, revert to abits */ - if (logbits == 0) - logbits = abits; - - /* determine the address and data bits */ - memset(space, 0, sizeof(*space)); - space->machine = machine; - space->cpu = machine->cpu[cpunum]; - space->name = address_space_names[spacenum]; - space->accessors = memory_accessors[accessorindex][(endianness == ENDIANNESS_LITTLE) ? 0 : 1]; - space->addrmask = 0xffffffffUL >> (32 - abits); - space->bytemask = (ashift < 0) ? ((space->addrmask << -ashift) | ((1 << -ashift) - 1)) : (space->addrmask >> ashift); - space->logaddrmask = 0xffffffffUL >> (32 - logbits); - space->logbytemask = (ashift < 0) ? ((space->logaddrmask << -ashift) | ((1 << -ashift) - 1)) : (space->logaddrmask >> ashift); - space->spacenum = spacenum; - space->endianness = endianness; - space->ashift = ashift; - space->pageshift = cputype_get_page_shift(cputype, spacenum); - space->abits = abits; - space->dbits = dbits; - space->addrchars = (abits + 3) / 4; - space->logaddrchars = (logbits + 3) / 4; - space->log_unmap = TRUE; - - /* allocate subtable information; we malloc this manually because it will be realloc'ed */ - space->read.subtable = auto_malloc(sizeof(*space->read.subtable) * SUBTABLE_COUNT); - memset(space->read.subtable, 0, sizeof(*space->read.subtable) * SUBTABLE_COUNT); - space->write.subtable = auto_malloc(sizeof(*space->write.subtable) * SUBTABLE_COUNT); - memset(space->write.subtable, 0, sizeof(*space->write.subtable) * SUBTABLE_COUNT); - - /* allocate the handler table */ - space->read.handlers[0] = auto_malloc(sizeof(*space->read.handlers[0]) * ARRAY_LENGTH(space->read.handlers)); - memset(space->read.handlers[0], 0, sizeof(*space->read.handlers[0]) * ARRAY_LENGTH(space->read.handlers)); - space->write.handlers[0] = auto_malloc(sizeof(*space->write.handlers[0]) * ARRAY_LENGTH(space->write.handlers)); - memset(space->write.handlers[0], 0, sizeof(*space->write.handlers[0]) * ARRAY_LENGTH(space->write.handlers)); - for (entrynum = 1; entrynum < ARRAY_LENGTH(space->read.handlers); entrynum++) - { - space->read.handlers[entrynum] = space->read.handlers[0] + entrynum; - space->write.handlers[entrynum] = space->write.handlers[0] + entrynum; - } - - /* init the static handlers */ - for (entrynum = 0; entrynum < ENTRY_COUNT; entrynum++) - { - space->read.handlers[entrynum]->handler.generic = get_static_handler(space->dbits, 0, entrynum); - space->read.handlers[entrynum]->object = space; - space->write.handlers[entrynum]->handler.generic = get_static_handler(space->dbits, 1, entrynum); - space->write.handlers[entrynum]->object = space; - } - - /* make sure we fix up the mask for the unmap and watchpoint handlers */ - space->read.handlers[STATIC_UNMAP]->bytemask = ~0; - space->write.handlers[STATIC_UNMAP]->bytemask = ~0; - space->read.handlers[STATIC_WATCHPOINT]->bytemask = ~0; - space->write.handlers[STATIC_WATCHPOINT]->bytemask = ~0; - - /* allocate memory; these aren't auto-malloc'ed as we need to expand them */ - space->read.table = malloc_or_die(1 << LEVEL1_BITS); - space->write.table = malloc_or_die(1 << LEVEL1_BITS); - - /* initialize everything to unmapped */ - memset(space->read.table, STATIC_UNMAP, 1 << LEVEL1_BITS); - memset(space->write.table, STATIC_UNMAP, 1 << LEVEL1_BITS); - - /* initialize the lookups */ - space->readlookup = space->read.table; - space->writelookup = space->write.table; - - /* set the direct access information base */ - space->direct.raw = space->direct.decrypted = NULL; - space->direct.mask = space->bytemask; - space->direct.min = 1; - space->direct.max = 0; - space->direct.entry = STATIC_UNMAP; - space->directupdate = NULL; - - /* link us in */ - *nextptr = space; - nextptr = (address_space **)&space->next; + space->read.handlers[entrynum] = space->read.handlers[0] + entrynum; + space->write.handlers[entrynum] = space->write.handlers[0] + entrynum; } - } + + /* init the static handlers */ + for (entrynum = 0; entrynum < ENTRY_COUNT; entrynum++) + { + space->read.handlers[entrynum]->handler.generic = get_static_handler(space->dbits, 0, entrynum); + space->read.handlers[entrynum]->object = space; + space->write.handlers[entrynum]->handler.generic = get_static_handler(space->dbits, 1, entrynum); + space->write.handlers[entrynum]->object = space; + } + + /* make sure we fix up the mask for the unmap and watchpoint handlers */ + space->read.handlers[STATIC_UNMAP]->bytemask = ~0; + space->write.handlers[STATIC_UNMAP]->bytemask = ~0; + space->read.handlers[STATIC_WATCHPOINT]->bytemask = ~0; + space->write.handlers[STATIC_WATCHPOINT]->bytemask = ~0; + + /* allocate memory; these aren't auto-malloc'ed as we need to expand them */ + space->read.table = malloc_or_die(1 << LEVEL1_BITS); + space->write.table = malloc_or_die(1 << LEVEL1_BITS); + + /* initialize everything to unmapped */ + memset(space->read.table, STATIC_UNMAP, 1 << LEVEL1_BITS); + memset(space->write.table, STATIC_UNMAP, 1 << LEVEL1_BITS); + + /* initialize the lookups */ + space->readlookup = space->read.table; + space->writelookup = space->write.table; + + /* set the direct access information base */ + space->direct.raw = space->direct.decrypted = NULL; + space->direct.mask = space->bytemask; + space->direct.min = 1; + space->direct.max = 0; + space->direct.entry = STATIC_UNMAP; + space->directupdate = NULL; + + /* link us in */ + *nextptr = space; + nextptr = (address_space **)&space->next; + } } @@ -1607,7 +1601,7 @@ static void memory_init_preflight(running_machine *machine) int entrynum; /* allocate the address map */ - space->map = address_map_alloc(machine->config, machine->gamedrv, cpu_get_index(space->cpu), space->spacenum); + space->map = address_map_alloc(space->cpu, machine->gamedrv, space->spacenum); /* extract global parameters specified by the map */ space->unmap = (space->map->unmapval == 0) ? 0 : ~0; diff --git a/src/emu/memory.h b/src/emu/memory.h index a76f0e36138..5f2f6fc7c5f 100644 --- a/src/emu/memory.h +++ b/src/emu/memory.h @@ -861,7 +861,7 @@ const address_space *memory_find_address_space(const device_config *cpu, int spa /* ----- address maps ----- */ /* build and allocate an address map for a CPU's address space */ -address_map *address_map_alloc(const machine_config *drv, const game_driver *driver, int cpunum, int spacenum); +address_map *address_map_alloc(const device_config *device, const game_driver *driver, int spacenum); /* release allocated memory for an address map */ void address_map_free(address_map *map); diff --git a/src/emu/romload.c b/src/emu/romload.c index ef12b5b33ee..caebebc8d6a 100644 --- a/src/emu/romload.c +++ b/src/emu/romload.c @@ -1173,19 +1173,18 @@ static UINT32 normalize_flags_for_cpu(running_machine *machine, UINT32 startflag const device_config *device = cputag_get_cpu(machine, rgntag); if (device != NULL) { - int cputype = ((const cpu_config *)device->inline_config)->type; int buswidth; /* set the endianness */ startflags &= ~ROMREGION_ENDIANMASK; - if (cputype_get_endianness(cputype) == ENDIANNESS_LITTLE) + if (cpu_get_endianness(device) == ENDIANNESS_LITTLE) startflags |= ROMREGION_LE; else startflags |= ROMREGION_BE; /* set the width */ startflags &= ~ROMREGION_WIDTHMASK; - buswidth = cputype_get_databus_width(cputype, ADDRESS_SPACE_PROGRAM); + buswidth = cpu_get_databus_width(device, ADDRESS_SPACE_PROGRAM); if (buswidth <= 8) startflags |= ROMREGION_8BIT; else if (buswidth <= 16) diff --git a/src/emu/sndintrf.c b/src/emu/sndintrf.c index 406f573b66f..5571f8098a0 100644 --- a/src/emu/sndintrf.c +++ b/src/emu/sndintrf.c @@ -575,7 +575,7 @@ void sndintrf_init(running_machine *machine) static DEVICE_GET_INFO( sndclass ) { - sndintrf_data *snddata = device->classtoken; + sndintrf_data *snddata = device->inline_config; (*snddata->intf.get_info)(device, state, (sndinfo *)info); } @@ -592,7 +592,9 @@ int sndintrf_init_sound(running_machine *machine, int sndnum, const char *tag, s info->device->static_config = config; info->device->region = memory_region(info->device->machine, info->device->tag); info->device->regionbytes = memory_region_length(info->device->machine, info->device->tag); - info->device->classtoken = info; + + /* hack: stash the info pointer in the inline_config */ + info->device->inline_config = info; /* fill in the type and interface */ info->intf = snd_type_header[sndtype]; diff --git a/src/emu/sound/nes_apu.c b/src/emu/sound/nes_apu.c index 186e400553a..f7a01a922a0 100644 --- a/src/emu/sound/nes_apu.c +++ b/src/emu/sound/nes_apu.c @@ -48,6 +48,7 @@ #include "cpuexec.h" #include "streams.h" #include "nes_apu.h" +#include "driver.h" #include "cpu/m6502/m6502.h" #include "nes_defs.h" diff --git a/src/emu/ui.c b/src/emu/ui.c index c4a4530598d..6032dbd3060 100644 --- a/src/emu/ui.c +++ b/src/emu/ui.c @@ -976,28 +976,30 @@ static astring *warnings_string(running_machine *machine, astring *string) astring *game_info_astring(running_machine *machine, astring *string) { int scrcount = video_screen_count(machine->config); - int cpunum, sndnum; + const device_config *scandevice; + const device_config *device; + int sndnum; int count; /* print description, manufacturer, and CPU: */ astring_printf(string, "%s\n%s %s\n\nCPU:\n", machine->gamedrv->description, machine->gamedrv->year, machine->gamedrv->manufacturer); /* loop over all CPUs */ - for (cpunum = 0; cpunum < MAX_CPU && machine->config->cpu[cpunum].type != CPU_DUMMY; cpunum += count) + for (device = machine->cpu[0]; device != NULL; device = scandevice) { - cpu_type type = machine->config->cpu[cpunum].type; - int clock = machine->config->cpu[cpunum].clock; + int clock = ((const cpu_config *)device->inline_config)->clock; /* count how many identical CPUs we have */ - for (count = 1; cpunum + count < MAX_CPU; count++) - if (machine->config->cpu[cpunum + count].type != type || - machine->config->cpu[cpunum + count].clock != clock) - break; + count = 1; + for (scandevice = device->typenext; scandevice != NULL; scandevice = device->typenext) + if (cpu_get_type(device) != cpu_get_type(scandevice) || + clock != ((const cpu_config *)scandevice->inline_config)->clock) + break; /* if more than one, prepend a #x in front of the CPU name */ if (count > 1) astring_catprintf(string, "%d" UTF8_MULTIPLY, count); - astring_catc(string, cputype_get_name(type)); + astring_catc(string, cpu_get_name(device)); /* display clock in kHz or MHz */ if (clock >= 1000000) diff --git a/src/emu/validity.c b/src/emu/validity.c index ed22bb9cea9..c94fd443ef5 100644 --- a/src/emu/validity.c +++ b/src/emu/validity.c @@ -714,51 +714,18 @@ static int validate_cpu(int drivnum, const machine_config *config, const input_p { const game_driver *driver = drivers[drivnum]; cpu_validity_check_func cpu_validity_check; + const device_config *device; int error = FALSE; - int cpunum; /* loop over all the CPUs */ - for (cpunum = 0; cpunum < MAX_CPU; cpunum++) + for (device = cpu_first(config); device != NULL; device = cpu_next(device)) { - const cpu_config *cpu = &config->cpu[cpunum]; - int spacenum, checknum; - - /* skip empty entries */ - if (cpu->type == CPU_DUMMY) - continue; - - /* check for valid tag */ - if (cpu->tag == NULL) - { - mame_printf_error("%s: %s has NULL CPU tag\n", driver->source_file, driver->name); - error = TRUE; - } - - /* check for duplicate tags */ - else - { - for (checknum = 0; checknum < cpunum; checknum++) - if (config->cpu[checknum].tag != NULL && strcmp(cpu->tag, config->cpu[checknum].tag) == 0) - { - mame_printf_error("%s: %s has multiple CPUs tagged as '%s'\n", driver->source_file, driver->name, cpu->tag); - error = TRUE; - } - } - - /* validate the CPU tag */ - error |= validate_tag(driver, "CPU", cpu->tag); - - /* checks to see if this driver is using a dummy CPU */ - if (cpu->type == CPU_DUMMY) - { - mame_printf_error("%s: %s uses non-present CPU\n", driver->source_file, driver->name); - error = TRUE; - continue; - } + const cpu_config *cpuconfig = device->inline_config; + int spacenum; /* check the CPU for incompleteness */ - if (cputype_get_info_fct(cpu->type, CPUINFO_PTR_RESET) == NULL || - cputype_get_info_fct(cpu->type, CPUINFO_PTR_EXECUTE) == NULL) + if (cpu_get_info_fct(device, CPUINFO_PTR_RESET) == NULL || + cpu_get_info_fct(device, CPUINFO_PTR_EXECUTE) == NULL) { mame_printf_error("%s: %s uses an incomplete CPU\n", driver->source_file, driver->name); error = TRUE; @@ -766,33 +733,30 @@ static int validate_cpu(int drivnum, const machine_config *config, const input_p } /* check for CPU-specific validity check */ - cpu_validity_check = (cpu_validity_check_func) cputype_get_info_fct(cpu->type, CPUINFO_PTR_VALIDITY_CHECK); - if (cpu_validity_check != NULL) - { - if ((*cpu_validity_check)(driver, config->cpu[cpunum].reset_param)) - error = TRUE; - } + cpu_validity_check = (cpu_validity_check_func) cpu_get_info_fct(device, CPUINFO_PTR_VALIDITY_CHECK); + if (cpu_validity_check != NULL && (*cpu_validity_check)(driver, device->static_config)) + error = TRUE; /* loop over all address spaces */ for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) { #define SPACE_SHIFT(a) ((addr_shift < 0) ? ((a) << -addr_shift) : ((a) >> addr_shift)) #define SPACE_SHIFT_END(a) ((addr_shift < 0) ? (((a) << -addr_shift) | ((1 << -addr_shift) - 1)) : ((a) >> addr_shift)) - int databus_width = cputype_get_databus_width(cpu->type, spacenum); - int addr_shift = cputype_get_addrbus_shift(cpu->type, spacenum); + int databus_width = cpu_get_databus_width(device, spacenum); + int addr_shift = cpu_get_addrbus_shift(device, spacenum); int alignunit = databus_width/8; address_map_entry *entry; address_map *map; /* check to see that the same map is not used twice */ - if (cpu->address_map[spacenum][0] != NULL && cpu->address_map[spacenum][0] == cpu->address_map[spacenum][1]) + if (cpuconfig->address_map[spacenum] != NULL && cpuconfig->address_map[spacenum] == cpuconfig->address_map2[spacenum]) { - mame_printf_error("%s: %s uses identical memory maps for CPU #%d spacenum %d\n", driver->source_file, driver->name, cpunum, spacenum); + mame_printf_error("%s: %s uses identical memory maps for CPU '%s' spacenum %d\n", driver->source_file, driver->name, device->tag, spacenum); error = TRUE; } /* construct the maps */ - map = address_map_alloc(config, driver, cpunum, spacenum); + map = address_map_alloc(device, driver, spacenum); /* if this is an empty map, just skip it */ if (map->entrylist == NULL) @@ -804,12 +768,12 @@ static int validate_cpu(int drivnum, const machine_config *config, const input_p /* validate the global map parameters */ if (map->spacenum != spacenum) { - mame_printf_error("%s: %s CPU #%d space %d has address space %d handlers!\n", driver->source_file, driver->name, cpunum, spacenum, map->spacenum); + mame_printf_error("%s: %s CPU '%s' space %d has address space %d handlers!\n", driver->source_file, driver->name, device->tag, spacenum, map->spacenum); error = TRUE; } if (map->databits != databus_width) { - mame_printf_error("%s: %s cpu #%d uses wrong memory handlers for %s space! (width = %d, memory = %08x)\n", driver->source_file, driver->name, cpunum, address_space_names[spacenum], databus_width, map->databits); + mame_printf_error("%s: %s cpu '%s' uses wrong memory handlers for %s space! (width = %d, memory = %08x)\n", driver->source_file, driver->name, device->tag, address_space_names[spacenum], databus_width, map->databits); error = TRUE; } @@ -836,7 +800,7 @@ static int validate_cpu(int drivnum, const machine_config *config, const input_p /* if this is a program space, auto-assign implicit ROM entries */ if ((FPTR)entry->read.generic == STATIC_ROM && entry->region == NULL) { - entry->region = config->cpu[cpunum].tag; + entry->region = device->tag; entry->rgnoffs = entry->addrstart; } @@ -851,7 +815,7 @@ static int validate_cpu(int drivnum, const machine_config *config, const input_p /* stop if we hit an empty */ if (rgninfo->entries[rgnnum].tag == NULL) { - mame_printf_error("%s: %s CPU %d space %d memory map entry %X-%X references non-existant region \"%s\"\n", driver->source_file, driver->name, cpunum, spacenum, entry->addrstart, entry->addrend, entry->region); + mame_printf_error("%s: %s CPU '%s' %s space memory map entry %X-%X references non-existant region \"%s\"\n", driver->source_file, driver->name, device->tag, address_space_names[spacenum], entry->addrstart, entry->addrend, entry->region); error = TRUE; break; } @@ -862,7 +826,7 @@ static int validate_cpu(int drivnum, const machine_config *config, const input_p offs_t length = rgninfo->entries[rgnnum].length; if (entry->rgnoffs + (byteend - bytestart + 1) > length) { - mame_printf_error("%s: %s CPU %d space %d memory map entry %X-%X extends beyond region \"%s\" size (%X)\n", driver->source_file, driver->name, cpunum, spacenum, entry->addrstart, entry->addrend, entry->region, length); + mame_printf_error("%s: %s CPU '%s' %s space memory map entry %X-%X extends beyond region \"%s\" size (%X)\n", driver->source_file, driver->name, device->tag, address_space_names[spacenum], entry->addrstart, entry->addrend, entry->region, length); error = TRUE; } break; @@ -873,19 +837,19 @@ static int validate_cpu(int drivnum, const machine_config *config, const input_p /* make sure all devices exist */ if (entry->read_devtype != NULL && device_list_find_by_tag(config->devicelist, entry->read_devtype, entry->read_devtag) == NULL) { - mame_printf_error("%s: %s CPU %d space %d memory map entry references nonexistant device type %s, tag %s\n", driver->source_file, driver->name, cpunum, spacenum, devtype_get_name(entry->read_devtype), entry->read_devtag); + mame_printf_error("%s: %s CPU '%s' %s space memory map entry references nonexistant device type %s, tag %s\n", driver->source_file, driver->name, device->tag, address_space_names[spacenum], devtype_get_name(entry->read_devtype), entry->read_devtag); error = TRUE; } if (entry->write_devtype != NULL && device_list_find_by_tag(config->devicelist, entry->write_devtype, entry->write_devtag) == NULL) { - mame_printf_error("%s: %s CPU %d space %d memory map entry references nonexistant device type %s, tag %s\n", driver->source_file, driver->name, cpunum, spacenum, devtype_get_name(entry->write_devtype), entry->write_devtag); + mame_printf_error("%s: %s CPU '%s' %s space memory map entry references nonexistant device type %s, tag %s\n", driver->source_file, driver->name, device->tag, address_space_names[spacenum], devtype_get_name(entry->write_devtype), entry->write_devtag); error = TRUE; } /* make sure ports exist */ if (entry->read_porttag != NULL && input_port_by_tag(portlist, entry->read_porttag) == NULL) { - mame_printf_error("%s: %s CPU %d space %d memory map entry references nonexistant port tag %s\n", driver->source_file, driver->name, cpunum, spacenum, entry->read_porttag); + mame_printf_error("%s: %s CPU '%s' %s space memory map entry references nonexistant port tag %s\n", driver->source_file, driver->name, device->tag, address_space_names[spacenum], entry->read_porttag); error = TRUE; } } @@ -894,46 +858,43 @@ static int validate_cpu(int drivnum, const machine_config *config, const input_p address_map_free(map); /* validate the interrupts */ - if (cpu->vblank_interrupt != NULL) + if (cpuconfig->vblank_interrupt != NULL) { if (video_screen_count(config) == 0) { - mame_printf_error("%s: %s cpu #%d has a VBLANK interrupt, but the driver is screenless !\n", driver->source_file, driver->name, cpunum); + mame_printf_error("%s: %s cpu '%s' has a VBLANK interrupt, but the driver is screenless !\n", driver->source_file, driver->name, device->tag); error = TRUE; } - else if (cpu->vblank_interrupts_per_frame == 0) + else if (cpuconfig->vblank_interrupt_screen != NULL && cpuconfig->vblank_interrupts_per_frame != 0) { - mame_printf_error("%s: %s cpu #%d has a VBLANK interrupt handler with 0 interrupts!\n", driver->source_file, driver->name, cpunum); + mame_printf_error("%s: %s cpu '%s' has a new VBLANK interrupt handler with >1 interrupts!\n", driver->source_file, driver->name, device->tag); error = TRUE; } - else if (cpu->vblank_interrupts_per_frame == 1) + else if (cpuconfig->vblank_interrupt_screen != NULL && device_list_find_by_tag(config->devicelist, VIDEO_SCREEN, cpuconfig->vblank_interrupt_screen) == NULL) { - if (cpu->vblank_interrupt_screen == NULL) - { - mame_printf_error("%s: %s cpu #%d has a valid VBLANK interrupt handler with no screen tag supplied!\n", driver->source_file, driver->name, cpunum); - error = TRUE; - } - else if (device_list_index(config->devicelist, VIDEO_SCREEN, cpu->vblank_interrupt_screen) == -1) - { - mame_printf_error("%s: %s cpu #%d VBLANK interrupt with a non-existant screen tag (%s)!\n", driver->source_file, driver->name, cpunum, cpu->vblank_interrupt_screen); - error = TRUE; - } + mame_printf_error("%s: %s cpu '%s' VBLANK interrupt with a non-existant screen tag (%s)!\n", driver->source_file, driver->name, device->tag, cpuconfig->vblank_interrupt_screen); + error = TRUE; + } + else if (cpuconfig->vblank_interrupt_screen == NULL && cpuconfig->vblank_interrupts_per_frame == 0) + { + mame_printf_error("%s: %s cpu '%s' has a VBLANK interrupt handler with 0 interrupts!\n", driver->source_file, driver->name, device->tag); + error = TRUE; } } - else if (cpu->vblank_interrupts_per_frame != 0) + else if (cpuconfig->vblank_interrupts_per_frame != 0) { - mame_printf_error("%s: %s cpu #%d has no VBLANK interrupt handler but a non-0 interrupt count is given!\n", driver->source_file, driver->name, cpunum); + mame_printf_error("%s: %s cpu '%s' has no VBLANK interrupt handler but a non-0 interrupt count is given!\n", driver->source_file, driver->name, device->tag); error = TRUE; } - if ((cpu->timed_interrupt != NULL) && (cpu->timed_interrupt_period == 0)) + if (cpuconfig->timed_interrupt != NULL && cpuconfig->timed_interrupt_period == 0) { - mame_printf_error("%s: %s cpu #%d has a timer interrupt handler with 0 period!\n", driver->source_file, driver->name, cpunum); + mame_printf_error("%s: %s cpu '%s' has a timer interrupt handler with 0 period!\n", driver->source_file, driver->name, device->tag); error = TRUE; } - else if ((cpu->timed_interrupt == NULL) && (cpu->timed_interrupt_period != 0)) + else if (cpuconfig->timed_interrupt == NULL && cpuconfig->timed_interrupt_period != 0) { - mame_printf_error("%s: %s cpu #%d has a no timer interrupt handler but has a non-0 period given!\n", driver->source_file, driver->name, cpunum); + mame_printf_error("%s: %s cpu '%s' has a no timer interrupt handler but has a non-0 period given!\n", driver->source_file, driver->name, device->tag); error = TRUE; } } diff --git a/src/emu/video.c b/src/emu/video.c index 068147578e5..a5343af5249 100644 --- a/src/emu/video.c +++ b/src/emu/video.c @@ -326,9 +326,6 @@ void video_init(running_machine *machine) global.frameskip_level = options_get_int(mame_options(), OPTION_FRAMESKIP); global.seconds_to_run = options_get_int(mame_options(), OPTION_SECONDS_TO_RUN); - /* set the first screen device as the primary - this will set NULL if screenless */ - machine->primary_screen = video_screen_first(machine->config); - /* create spriteram buffers if necessary */ if (machine->config->video_attributes & VIDEO_BUFFERS_SPRITERAM) init_buffered_spriteram(machine); @@ -1110,7 +1107,7 @@ attotime video_screen_get_frame_period(const device_config *screen) /* a lot of modules want to the period of the primary screen, so if we are screenless, return something reasonable so that we don't fall over */ - if (screen == NULL || video_screen_count(screen->machine->config) == 0) + if (screen == NULL || !screen->started || video_screen_count(screen->machine->config) == 0) { ret = DEFAULT_FRAME_PERIOD; } diff --git a/src/mame/audio/mario.c b/src/mame/audio/mario.c index ea90613d5a5..62a6b66b31c 100644 --- a/src/mame/audio/mario.c +++ b/src/mame/audio/mario.c @@ -264,7 +264,7 @@ static SOUND_START( mario ) #endif state->eabank = 0; - if (audiocpu != NULL && ((const cpu_class_header *)audiocpu->classtoken)->cputype != CPU_Z80) + if (audiocpu != NULL && cpu_get_type(audiocpu) != CPU_Z80) { state->eabank = 1; memory_install_read8_handler(cpu_get_address_space(audiocpu, ADDRESS_SPACE_PROGRAM), 0x000, 0x7ff, 0, 0, SMH_BANK1); diff --git a/src/mame/audio/namcoc7x.c b/src/mame/audio/namcoc7x.c index 3b7c297c5d6..41f00ba882c 100644 --- a/src/mame/audio/namcoc7x.c +++ b/src/mame/audio/namcoc7x.c @@ -79,7 +79,7 @@ void namcoc7x_sound_write16(UINT16 command, UINT32 offset) void namcoc7x_on_driver_init(running_machine *machine) { UINT8 *pROM = (UINT8 *)memory_region(machine, "c7x"); - int cpunum; + const device_config *cpu; // clear the two 16-bits magic values at the start of the rom // (prevents external init routines from getting called - they assume a @@ -87,9 +87,9 @@ void namcoc7x_on_driver_init(running_machine *machine) memset(pROM, 0, 4); // install speedup cheat - for (cpunum = 0; cpunum < MAX_CPU; cpunum++) - if (machine->config->cpu[cpunum].type == CPU_M37702) - memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[cpunum], ADDRESS_SPACE_PROGRAM), 0x82, 0x83, 0, 0, speedup_r, speedup_w); + for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + if (cpu_get_type(cpu) == CPU_M37702) + memory_install_readwrite16_handler(cpu_get_address_space(cpu, ADDRESS_SPACE_PROGRAM), 0x82, 0x83, 0, 0, speedup_r, speedup_w); } void namcoc7x_set_host_ram(UINT32 *hostram) diff --git a/src/mame/drivers/20pacgal.c b/src/mame/drivers/20pacgal.c index 44b09154c35..05f4546cb1f 100644 --- a/src/mame/drivers/20pacgal.c +++ b/src/mame/drivers/20pacgal.c @@ -65,7 +65,7 @@ static WRITE8_HANDLER( irqack_w ) { int bit = data & 1; - cpu_interrupt_enable(0, bit); + cpu_interrupt_enable(space->machine->cpu[0], bit); if (!bit) cpu_set_input_line(space->machine->cpu[0], 0, CLEAR_LINE ); diff --git a/src/mame/drivers/atarig1.c b/src/mame/drivers/atarig1.c index aa9754123b0..92c5f7ceb22 100644 --- a/src/mame/drivers/atarig1.c +++ b/src/mame/drivers/atarig1.c @@ -955,7 +955,7 @@ static void init_g1_common(running_machine *machine, offs_t slapstic_base, int s state_save_register_postload(machine, pitfighb_state_postload, NULL); } else if (slapstic != 0) - atarigen_slapstic_init(machine, 0, slapstic_base, 0, slapstic); + atarigen_slapstic_init(machine->cpu[0], slapstic_base, 0, slapstic); atarijsa_init(machine, "IN0", 0x4000); atarig1_pitfight = is_pitfight; diff --git a/src/mame/drivers/atarisy1.c b/src/mame/drivers/atarisy1.c index 646180cef15..1e847c66182 100644 --- a/src/mame/drivers/atarisy1.c +++ b/src/mame/drivers/atarisy1.c @@ -2146,7 +2146,7 @@ ROM_END static DRIVER_INIT( marble ) { atarigen_eeprom_default = NULL; - atarigen_slapstic_init(machine, 0, 0x080000, 0, 103); + atarigen_slapstic_init(machine->cpu[0], 0x080000, 0, 103); joystick_type = 0; /* none */ trackball_type = 1; /* rotated */ @@ -2156,7 +2156,7 @@ static DRIVER_INIT( marble ) static DRIVER_INIT( peterpak ) { atarigen_eeprom_default = NULL; - atarigen_slapstic_init(machine, 0, 0x080000, 0, 107); + atarigen_slapstic_init(machine->cpu[0], 0x080000, 0, 107); joystick_type = 1; /* digital */ trackball_type = 0; /* none */ @@ -2166,7 +2166,7 @@ static DRIVER_INIT( peterpak ) static DRIVER_INIT( indytemp ) { atarigen_eeprom_default = NULL; - atarigen_slapstic_init(machine, 0, 0x080000, 0, 105); + atarigen_slapstic_init(machine->cpu[0], 0x080000, 0, 105); joystick_type = 1; /* digital */ trackball_type = 0; /* none */ @@ -2176,7 +2176,7 @@ static DRIVER_INIT( indytemp ) static DRIVER_INIT( roadrunn ) { atarigen_eeprom_default = NULL; - atarigen_slapstic_init(machine, 0, 0x080000, 0, 108); + atarigen_slapstic_init(machine->cpu[0], 0x080000, 0, 108); joystick_type = 2; /* analog */ trackball_type = 0; /* none */ @@ -2186,7 +2186,7 @@ static DRIVER_INIT( roadrunn ) static DRIVER_INIT( roadb109 ) { atarigen_eeprom_default = NULL; - atarigen_slapstic_init(machine, 0, 0x080000, 0, 109); + atarigen_slapstic_init(machine->cpu[0], 0x080000, 0, 109); joystick_type = 3; /* pedal */ trackball_type = 2; /* steering wheel */ @@ -2196,7 +2196,7 @@ static DRIVER_INIT( roadb109 ) static DRIVER_INIT( roadb110 ) { atarigen_eeprom_default = NULL; - atarigen_slapstic_init(machine, 0, 0x080000, 0, 110); + atarigen_slapstic_init(machine->cpu[0], 0x080000, 0, 110); joystick_type = 3; /* pedal */ trackball_type = 2; /* steering wheel */ diff --git a/src/mame/drivers/brkthru.c b/src/mame/drivers/brkthru.c index 673557e9359..b2c41f56b40 100644 --- a/src/mame/drivers/brkthru.c +++ b/src/mame/drivers/brkthru.c @@ -72,16 +72,16 @@ VIDEO_UPDATE( brkthru ); static WRITE8_HANDLER( brkthru_1803_w ) { /* bit 0 = NMI enable */ - cpu_interrupt_enable(0, ~data & 1); + cpu_interrupt_enable(space->machine->cpu[0], ~data & 1); /* bit 1 = ? maybe IRQ acknowledge */ } static WRITE8_HANDLER( darwin_0803_w ) { /* bit 0 = NMI enable */ - /*cpu_interrupt_enable(1, ~data & 1);*/ + /*cpu_interrupt_enable(space->machine->cpu[1], ~data & 1);*/ logerror("0803 %02X\n",data); - cpu_interrupt_enable(0, data & 1); + cpu_interrupt_enable(space->machine->cpu[0], data & 1); /* bit 1 = ? maybe IRQ acknowledge */ } diff --git a/src/mame/drivers/cclimber.c b/src/mame/drivers/cclimber.c index dabf57d2dea..7b3997ce48e 100644 --- a/src/mame/drivers/cclimber.c +++ b/src/mame/drivers/cclimber.c @@ -247,7 +247,7 @@ static WRITE8_HANDLER(toprollr_rombank_w) static TIMER_CALLBACK( disable_interrupts ) { - cpu_interrupt_enable(0,0); + cpu_interrupt_enable(machine->cpu[0],0); } diff --git a/src/mame/drivers/champbas.c b/src/mame/drivers/champbas.c index 67c190ab6b6..1da29a60198 100644 --- a/src/mame/drivers/champbas.c +++ b/src/mame/drivers/champbas.c @@ -128,7 +128,7 @@ static WRITE8_HANDLER( irq_enable_w ) { int bit = data & 1; - cpu_interrupt_enable(0,bit); + cpu_interrupt_enable(space->machine->cpu[0],bit); if (!bit) cpu_set_input_line(space->machine->cpu[0], 0, CLEAR_LINE); } diff --git a/src/mame/drivers/cojag.c b/src/mame/drivers/cojag.c index 8d1ff5d2bf3..9b068ab2b61 100644 --- a/src/mame/drivers/cojag.c +++ b/src/mame/drivers/cojag.c @@ -1504,7 +1504,7 @@ ROM_END static void cojag_common_init(running_machine *machine, UINT16 gpu_jump_offs, UINT16 spin_pc) { /* copy over the ROM */ - cojag_is_r3000 = (machine->config->cpu[0].type == CPU_R3041BE); + cojag_is_r3000 = (cpu_get_type(machine->cpu[0]) == CPU_R3041BE); /* install synchronization hooks for GPU */ if (cojag_is_r3000) diff --git a/src/mame/drivers/crbaloon.c b/src/mame/drivers/crbaloon.c index 64d000136ad..83347fa3497 100644 --- a/src/mame/drivers/crbaloon.c +++ b/src/mame/drivers/crbaloon.c @@ -159,7 +159,7 @@ static READ8_HANDLER( pc3259_r ) static WRITE8_HANDLER( port_sound_w ) { /* D0 - interrupt enable - also goes to PC3259 as /HTCTRL */ - cpu_interrupt_enable(0, (data & 0x01) ? TRUE : FALSE); + cpu_interrupt_enable(space->machine->cpu[0], (data & 0x01) ? TRUE : FALSE); crbaloon_set_clear_collision_address((data & 0x01) ? TRUE : FALSE); /* D1 - SOUND STOP */ diff --git a/src/mame/drivers/cyberbal.c b/src/mame/drivers/cyberbal.c index 01419d7622e..c463bea4380 100644 --- a/src/mame/drivers/cyberbal.c +++ b/src/mame/drivers/cyberbal.c @@ -971,14 +971,14 @@ static const UINT16 default_eeprom[] = static DRIVER_INIT( cyberbal ) { atarigen_eeprom_default = default_eeprom; - atarigen_slapstic_init(machine, 0, 0x018000, 0, 0); + atarigen_slapstic_init(machine->cpu[0], 0x018000, 0, 0); } static DRIVER_INIT( cyberbt ) { atarigen_eeprom_default = default_eeprom; - atarigen_slapstic_init(machine, 0, 0x018000, 0, 116); + atarigen_slapstic_init(machine->cpu[0], 0x018000, 0, 116); } diff --git a/src/mame/drivers/deniam.c b/src/mame/drivers/deniam.c index a90f7f2d078..1b18dcd61db 100644 --- a/src/mame/drivers/deniam.c +++ b/src/mame/drivers/deniam.c @@ -262,7 +262,7 @@ GFXDECODE_END static void irqhandler(running_machine *machine, int linestate) { /* system 16c doesn't have the sound CPU */ - if (machine->config->cpu[1].type != CPU_DUMMY) + if (machine->cpu[1] != NULL) cpu_set_input_line(machine->cpu[1],0,linestate); } diff --git a/src/mame/drivers/dkong.c b/src/mame/drivers/dkong.c index 016abcaf6ca..65d0098ed0f 100644 --- a/src/mame/drivers/dkong.c +++ b/src/mame/drivers/dkong.c @@ -338,7 +338,7 @@ static WRITE8_DEVICE_HANDLER( p8257_ctl_w ); static const z80dma_interface dk3_dma = { - 0, + "main", CLOCK_1H, dk_dma_read_byte, @@ -349,7 +349,7 @@ static const z80dma_interface dk3_dma = static const dma8257_interface dk_dma = { - 0, + "main", CLOCK_1H, dk_dma_read_byte, @@ -362,7 +362,7 @@ static const dma8257_interface dk_dma = static const dma8257_interface hb_dma = { - 0, + "main", CLOCK_1H, hb_dma_read_byte, diff --git a/src/mame/drivers/espial.c b/src/mame/drivers/espial.c index 91f76aa1e88..0658349703e 100644 --- a/src/mame/drivers/espial.c +++ b/src/mame/drivers/espial.c @@ -19,7 +19,7 @@ static UINT8 sound_nmi_enabled; static TIMER_CALLBACK( interrupt_disable ) { //interrupt_enable = 0; - cpu_interrupt_enable(0,0); + cpu_interrupt_enable(machine->cpu[0],0); } MACHINE_RESET( espial ) diff --git a/src/mame/drivers/filetto.c b/src/mame/drivers/filetto.c index a61e14210de..ed94c658cad 100644 --- a/src/mame/drivers/filetto.c +++ b/src/mame/drivers/filetto.c @@ -613,7 +613,7 @@ static WRITE8_HANDLER(dma_page_select_w) static const struct dma8237_interface dma8237_1_config = { - 0, + "main", 1.0e-6, // 1us pc_dma_read_byte, diff --git a/src/mame/drivers/galaga.c b/src/mame/drivers/galaga.c index cddd6630556..7dce653bd37 100644 --- a/src/mame/drivers/galaga.c +++ b/src/mame/drivers/galaga.c @@ -741,19 +741,19 @@ static WRITE8_HANDLER( bosco_latch_w ) switch (offset) { case 0x00: /* IRQ1 */ - cpu_interrupt_enable(0,bit); + cpu_interrupt_enable(space->machine->cpu[0],bit); if (!bit) cpu_set_input_line(space->machine->cpu[0], 0, CLEAR_LINE); break; case 0x01: /* IRQ2 */ - cpu_interrupt_enable(1,bit); + cpu_interrupt_enable(space->machine->cpu[1],bit); if (!bit) cpu_set_input_line(space->machine->cpu[1], 0, CLEAR_LINE); break; case 0x02: /* NMION */ - cpu_interrupt_enable(2,!bit); + cpu_interrupt_enable(space->machine->cpu[2],!bit); break; case 0x03: /* RESET */ diff --git a/src/mame/drivers/gamecstl.c b/src/mame/drivers/gamecstl.c index 1e071a5b343..92d0cc7e1fd 100644 --- a/src/mame/drivers/gamecstl.c +++ b/src/mame/drivers/gamecstl.c @@ -441,7 +441,7 @@ static DMA8237_MEM_WRITE( pc_dma_write_byte ) static const struct dma8237_interface dma8237_1_config = { - 0, + "main", 1.0e-6, // 1us pc_dma_read_byte, @@ -455,7 +455,7 @@ static const struct dma8237_interface dma8237_1_config = static const struct dma8237_interface dma8237_2_config = { - 0, + "main", 1.0e-6, // 1us NULL, diff --git a/src/mame/drivers/gaplus.c b/src/mame/drivers/gaplus.c index c7670811323..a5f25286d9b 100644 --- a/src/mame/drivers/gaplus.c +++ b/src/mame/drivers/gaplus.c @@ -255,7 +255,7 @@ static WRITE8_HANDLER( gaplus_snd_sharedram_w ) static WRITE8_HANDLER( gaplus_irq_1_ctrl_w ) { int bit = !BIT(offset,11); - cpu_interrupt_enable(0,bit); + cpu_interrupt_enable(space->machine->cpu[0],bit); if (!bit) cpu_set_input_line(space->machine->cpu[0], 0, CLEAR_LINE); } @@ -263,7 +263,7 @@ static WRITE8_HANDLER( gaplus_irq_1_ctrl_w ) static WRITE8_HANDLER( gaplus_irq_3_ctrl_w ) { int bit = !BIT(offset,13); - cpu_interrupt_enable(2,bit); + cpu_interrupt_enable(space->machine->cpu[2],bit); if (!bit) cpu_set_input_line(space->machine->cpu[2], 0, CLEAR_LINE); } @@ -271,7 +271,7 @@ static WRITE8_HANDLER( gaplus_irq_3_ctrl_w ) static WRITE8_HANDLER( gaplus_irq_2_ctrl_w ) { int bit = offset & 1; - cpu_interrupt_enable(1,bit); + cpu_interrupt_enable(space->machine->cpu[1],bit); if (!bit) cpu_set_input_line(space->machine->cpu[1], 0, CLEAR_LINE); } @@ -295,7 +295,7 @@ logerror("%04x: freset %d\n",cpu_get_pc(space->cpu),bit); static MACHINE_RESET( gaplus ) { /* on reset, VINTON is reset, while the other flags don't seem to be affected */ - cpu_interrupt_enable(1,0); + cpu_interrupt_enable(machine->cpu[1],0); cpu_set_input_line(machine->cpu[1], 0, CLEAR_LINE); } diff --git a/src/mame/drivers/gauntlet.c b/src/mame/drivers/gauntlet.c index 685ace0fcff..4ba8dc3a374 100644 --- a/src/mame/drivers/gauntlet.c +++ b/src/mame/drivers/gauntlet.c @@ -1628,7 +1628,7 @@ static void gauntlet_common_init(running_machine *machine, int slapstic, int vin { UINT8 *rom = memory_region(machine, "main"); atarigen_eeprom_default = NULL; - atarigen_slapstic_init(machine, 0, 0x038000, 0, slapstic); + atarigen_slapstic_init(machine->cpu[0], 0x038000, 0, slapstic); /* swap the top and bottom halves of the main CPU ROM images */ atarigen_swap_mem(rom + 0x000000, rom + 0x008000, 0x8000); diff --git a/src/mame/drivers/genesis.c b/src/mame/drivers/genesis.c index bcb0d2b49cc..229ceb71250 100644 --- a/src/mame/drivers/genesis.c +++ b/src/mame/drivers/genesis.c @@ -148,7 +148,7 @@ MACHINE_START( genesis ) MACHINE_RESET( genesis ) { /* C2 doesn't have a Z80, so we can't just assume */ - if (machine->config->cpu[1].type == CPU_Z80) + if (machine->cpu[1] != NULL && cpu_get_type(machine->cpu[1]) == CPU_Z80) { /* the following ensures that the Z80 begins without running away from 0 */ /* 0x76 is just a forced 'halt' as soon as the CPU is initially run */ diff --git a/src/mame/drivers/harddriv.c b/src/mame/drivers/harddriv.c index 2079b51f4fd..76fba256cee 100644 --- a/src/mame/drivers/harddriv.c +++ b/src/mame/drivers/harddriv.c @@ -3461,10 +3461,10 @@ static void init_ds3(running_machine *machine) memory_install_write16_handler(cpu_get_address_space(hdcpu_main, ADDRESS_SPACE_PROGRAM), 0x823800, 0x823fff, 0, 0, hd68k_ds3_control_w); /* if we have a sound DSP, boot it */ - if (hdcpu_sound != NULL && ((const cpu_class_header *)hdcpu_sound->classtoken)->cputype == CPU_ADSP2105) + if (hdcpu_sound != NULL && cpu_get_type(hdcpu_sound) == CPU_ADSP2105) adsp2105_load_boot_data((UINT8 *)(hdcpu_sound->region + 0x10000), (UINT32 *)hdcpu_sound->region); - if (hdcpu_sounddsp != NULL && ((const cpu_class_header *)hdcpu_sounddsp->classtoken)->cputype == CPU_ADSP2105) + if (hdcpu_sounddsp != NULL && cpu_get_type(hdcpu_sounddsp) == CPU_ADSP2105) adsp2105_load_boot_data((UINT8 *)(hdcpu_sounddsp->region + 0x10000), (UINT32 *)hdcpu_sounddsp->region); /* diff --git a/src/mame/drivers/itech8.c b/src/mame/drivers/itech8.c index 167e64d4d81..240c49b5a30 100644 --- a/src/mame/drivers/itech8.c +++ b/src/mame/drivers/itech8.c @@ -589,13 +589,15 @@ static const via6522_interface via_interface = void itech8_update_interrupts(running_machine *machine, int periodic, int tms34061, int blitter) { + cpu_type main_cpu_type = cpu_get_type(machine->cpu[0]); + /* update the states */ if (periodic != -1) periodic_int = periodic; if (tms34061 != -1) tms34061_int = tms34061; if (blitter != -1) blitter_int = blitter; /* handle the 6809 case */ - if (machine->config->cpu[0].type == CPU_M6809 || machine->config->cpu[0].type == CPU_HD6309) + if (main_cpu_type == CPU_M6809 || main_cpu_type == CPU_HD6309) { /* just modify lines that have changed */ if (periodic != -1) cpu_set_input_line(machine->cpu[0], INPUT_LINE_NMI, periodic ? ASSERT_LINE : CLEAR_LINE); @@ -673,8 +675,10 @@ static MACHINE_START( sstrike ) static MACHINE_RESET( itech8 ) { + cpu_type main_cpu_type = cpu_get_type(machine->cpu[0]); + /* make sure bank 0 is selected */ - if (machine->config->cpu[0].type == CPU_M6809 || machine->config->cpu[0].type == CPU_HD6309) + if (main_cpu_type == CPU_M6809 || main_cpu_type == CPU_HD6309) { memory_set_bankptr(machine, 1, &memory_region(machine, "main")[0x4000]); cpu_reset(machine->cpu[0]); diff --git a/src/mame/drivers/kyugo.c b/src/mame/drivers/kyugo.c index 80e59894c7e..390e86b58b5 100644 --- a/src/mame/drivers/kyugo.c +++ b/src/mame/drivers/kyugo.c @@ -40,7 +40,7 @@ MACHINE_RESET( kyugo ) { const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); // must start with interrupts and sub CPU disabled - cpu_interrupt_enable(0, 0); + cpu_interrupt_enable(machine->cpu[0], 0); kyugo_sub_cpu_control_w(space, 0, 0); } diff --git a/src/mame/drivers/mappy.c b/src/mame/drivers/mappy.c index f4967de3829..76463acb588 100644 --- a/src/mame/drivers/mappy.c +++ b/src/mame/drivers/mappy.c @@ -702,13 +702,13 @@ static WRITE8_HANDLER( superpac_latch_w ) switch (offset & 0x0e) { case 0x00: /* INT ON 2 */ - cpu_interrupt_enable(1,bit); + cpu_interrupt_enable(space->machine->cpu[1],bit); if (!bit) cpu_set_input_line(space->machine->cpu[1], 0, CLEAR_LINE); break; case 0x02: /* INT ON */ - cpu_interrupt_enable(0,bit); + cpu_interrupt_enable(space->machine->cpu[0],bit); if (!bit) cpu_set_input_line(space->machine->cpu[0], 0, CLEAR_LINE); break; @@ -744,19 +744,19 @@ static WRITE8_HANDLER( phozon_latch_w ) switch (offset & 0x0e) { case 0x00: - cpu_interrupt_enable(1,bit); + cpu_interrupt_enable(space->machine->cpu[1],bit); if (!bit) cpu_set_input_line(space->machine->cpu[1], 0, CLEAR_LINE); break; case 0x02: - cpu_interrupt_enable(0,bit); + cpu_interrupt_enable(space->machine->cpu[0],bit); if (!bit) cpu_set_input_line(space->machine->cpu[0], 0, CLEAR_LINE); break; case 0x04: - cpu_interrupt_enable(2,bit); + cpu_interrupt_enable(space->machine->cpu[2],bit); if (!bit) cpu_set_input_line(space->machine->cpu[2], 0, CLEAR_LINE); break; @@ -790,13 +790,13 @@ static WRITE8_HANDLER( mappy_latch_w ) switch (offset & 0x0e) { case 0x00: /* INT ON 2 */ - cpu_interrupt_enable(1,bit); + cpu_interrupt_enable(space->machine->cpu[1],bit); if (!bit) cpu_set_input_line(space->machine->cpu[1], 0, CLEAR_LINE); break; case 0x02: /* INT ON */ - cpu_interrupt_enable(0,bit); + cpu_interrupt_enable(space->machine->cpu[0],bit); if (!bit) cpu_set_input_line(space->machine->cpu[0], 0, CLEAR_LINE); break; diff --git a/src/mame/drivers/mario.c b/src/mame/drivers/mario.c index 5e1903e0d47..86e5d339537 100644 --- a/src/mame/drivers/mario.c +++ b/src/mame/drivers/mario.c @@ -105,7 +105,7 @@ static WRITE8_DEVICE_HANDLER(mario_dma_write_byte); static const z80dma_interface mario_dma = { - 0, + "main", Z80_CLOCK, mario_dma_read_byte, diff --git a/src/mame/drivers/mediagx.c b/src/mame/drivers/mediagx.c index bebd0fe2640..6ed49f6bf88 100644 --- a/src/mame/drivers/mediagx.c +++ b/src/mame/drivers/mediagx.c @@ -792,7 +792,7 @@ static DMA8237_MEM_WRITE( pc_dma_write_byte ) static const struct dma8237_interface dma8237_1_config = { - 0, + "main", 1.0e-6, // 1us pc_dma_read_byte, @@ -806,7 +806,7 @@ static const struct dma8237_interface dma8237_1_config = static const struct dma8237_interface dma8237_2_config = { - 0, + "main", 1.0e-6, // 1us NULL, diff --git a/src/mame/drivers/nbmj8991.c b/src/mame/drivers/nbmj8991.c index 11b17df944f..673df4b7d7d 100644 --- a/src/mame/drivers/nbmj8991.c +++ b/src/mame/drivers/nbmj8991.c @@ -68,7 +68,7 @@ static READ8_HANDLER( nbmj8991_sound_r ) static MACHINE_RESET( nbmj8991 ) { - if (machine->config->cpu[1].type == CPU_Z80) + if (cpu_get_type(machine->cpu[1]) == CPU_Z80) { memory_configure_bank(machine, 1, 0, 4, memory_region(machine, "audio") + 0x8000, 0x8000); memory_set_bank(machine, 1, 0); diff --git a/src/mame/drivers/pacland.c b/src/mame/drivers/pacland.c index d5fad0c4550..5f83d9bdb58 100644 --- a/src/mame/drivers/pacland.c +++ b/src/mame/drivers/pacland.c @@ -232,7 +232,7 @@ static WRITE8_HANDLER( pacland_led_w ) static WRITE8_HANDLER( pacland_irq_1_ctrl_w ) { int bit = !BIT(offset,11); - cpu_interrupt_enable(0,bit); + cpu_interrupt_enable(space->machine->cpu[0],bit); if (!bit) cpu_set_input_line(space->machine->cpu[0], 0, CLEAR_LINE); } @@ -240,7 +240,7 @@ static WRITE8_HANDLER( pacland_irq_1_ctrl_w ) static WRITE8_HANDLER( pacland_irq_2_ctrl_w ) { int bit = !BIT(offset,13); - cpu_interrupt_enable(1,bit); + cpu_interrupt_enable(space->machine->cpu[1],bit); if (!bit) cpu_set_input_line(space->machine->cpu[1], 0, CLEAR_LINE); } diff --git a/src/mame/drivers/polepos.c b/src/mame/drivers/polepos.c index 4aecaa0d61c..df94db47b13 100644 --- a/src/mame/drivers/polepos.c +++ b/src/mame/drivers/polepos.c @@ -286,7 +286,7 @@ static WRITE8_HANDLER( polepos_latch_w ) switch (offset) { case 0x00: /* IRQON */ - cpu_interrupt_enable(0,bit); + cpu_interrupt_enable(space->machine->cpu[0],bit); if (!bit) cpu_set_input_line(space->machine->cpu[0], 0, CLEAR_LINE); break; @@ -330,7 +330,7 @@ static WRITE16_HANDLER( polepos_z8002_nvi_enable_w ) { data &= 1; - cpu_interrupt_enable(cpu_get_index(space->cpu),data); + cpu_interrupt_enable(space->cpu,data); if (!data) cpu_set_input_line(space->cpu, 0, CLEAR_LINE); } diff --git a/src/mame/drivers/rallyx.c b/src/mame/drivers/rallyx.c index d9c655490cb..7fd05b35123 100644 --- a/src/mame/drivers/rallyx.c +++ b/src/mame/drivers/rallyx.c @@ -240,7 +240,7 @@ static WRITE8_HANDLER( rallyx_latch_w ) break; case 0x01: /* INT ON */ - cpu_interrupt_enable(0,bit); + cpu_interrupt_enable(space->machine->cpu[0],bit); if (!bit) cpu_set_input_line(space->machine->cpu[0], 0, CLEAR_LINE); break; @@ -284,7 +284,7 @@ static WRITE8_HANDLER( locomotn_latch_w ) break; case 0x01: /* INTST */ - cpu_interrupt_enable(0,bit); + cpu_interrupt_enable(space->machine->cpu[0],bit); break; case 0x02: /* MUT */ diff --git a/src/mame/drivers/rampart.c b/src/mame/drivers/rampart.c index 79001dfc1af..2fe0a992426 100644 --- a/src/mame/drivers/rampart.c +++ b/src/mame/drivers/rampart.c @@ -528,7 +528,7 @@ static DRIVER_INIT( rampart ) atarigen_eeprom_default = compressed_default_eeprom; memcpy(&rom[0x140000], &rom[0x40000], 0x8000); - atarigen_slapstic_init(machine, 0, 0x140000, 0x438000, 118); + atarigen_slapstic_init(machine->cpu[0], 0x140000, 0x438000, 118); } diff --git a/src/mame/drivers/retofinv.c b/src/mame/drivers/retofinv.c index e53549bf554..52686590cf6 100644 --- a/src/mame/drivers/retofinv.c +++ b/src/mame/drivers/retofinv.c @@ -74,7 +74,7 @@ static WRITE8_HANDLER( irq0_ack_w ) { int bit = data & 1; - cpu_interrupt_enable(0,bit); + cpu_interrupt_enable(space->machine->cpu[0],bit); if (!bit) cpu_set_input_line(space->machine->cpu[0], 0, CLEAR_LINE); } @@ -83,7 +83,7 @@ static WRITE8_HANDLER( irq1_ack_w ) { int bit = data & 1; - cpu_interrupt_enable(1,bit); + cpu_interrupt_enable(space->machine->cpu[1],bit); if (!bit) cpu_set_input_line(space->machine->cpu[1], 0, CLEAR_LINE); } diff --git a/src/mame/drivers/segas18.c b/src/mame/drivers/segas18.c index 9f9c4ea1c2c..68829be6de3 100644 --- a/src/mame/drivers/segas18.c +++ b/src/mame/drivers/segas18.c @@ -202,7 +202,7 @@ static MACHINE_RESET( system18 ) fd1094_machine_init(machine->cpu[0]); /* if we are running with a real live 8751, we need to boost the interleave at startup */ - if (machine->config->cpu[2].type == CPU_I8751) + if (machine->cpu[2] != NULL && cpu_get_type(machine->cpu[2]) == CPU_I8751) timer_call_after_resynch(machine, NULL, 0, boost_interleave); } diff --git a/src/mame/drivers/seibuspi.c b/src/mame/drivers/seibuspi.c index 7c23d4be006..c64b3d7f666 100644 --- a/src/mame/drivers/seibuspi.c +++ b/src/mame/drivers/seibuspi.c @@ -1737,7 +1737,7 @@ static MACHINE_RESET( spi ) static MACHINE_DRIVER_START( spi ) /* basic machine hardware */ - MDRV_CPU_ADD("main",I386, 50000000/2) /* Intel 386DX, 25MHz */ + MDRV_CPU_ADD("main", I386, 50000000/2) /* Intel 386DX, 25MHz */ MDRV_CPU_PROGRAM_MAP(spi_map, 0) MDRV_CPU_VBLANK_INT("main", spi_interrupt) diff --git a/src/mame/drivers/seicross.c b/src/mame/drivers/seicross.c index 78084faebe3..7639452e44b 100644 --- a/src/mame/drivers/seicross.c +++ b/src/mame/drivers/seicross.c @@ -98,7 +98,7 @@ static WRITE8_HANDLER( friskyt_portB_w ) { //logerror("PC %04x: 8910 port B = %02x\n",cpu_get_pc(space->cpu),data); /* bit 0 is IRQ enable */ - cpu_interrupt_enable(0,data & 1); + cpu_interrupt_enable(space->machine->cpu[0],data & 1); /* bit 1 flips screen */ diff --git a/src/mame/drivers/skykid.c b/src/mame/drivers/skykid.c index 66393035113..7b751b830e7 100644 --- a/src/mame/drivers/skykid.c +++ b/src/mame/drivers/skykid.c @@ -90,7 +90,7 @@ static WRITE8_HANDLER( skykid_bankswitch_w ) static WRITE8_HANDLER( skykid_irq_1_ctrl_w ) { int bit = !BIT(offset,11); - cpu_interrupt_enable(0,bit); + cpu_interrupt_enable(space->machine->cpu[0],bit); if (!bit) cpu_set_input_line(space->machine->cpu[0], 0, CLEAR_LINE); } @@ -98,7 +98,7 @@ static WRITE8_HANDLER( skykid_irq_1_ctrl_w ) static WRITE8_HANDLER( skykid_irq_2_ctrl_w ) { int bit = !BIT(offset,13); - cpu_interrupt_enable(1,bit); + cpu_interrupt_enable(space->machine->cpu[1],bit); if (!bit) cpu_set_input_line(space->machine->cpu[1], 0, CLEAR_LINE); } diff --git a/src/mame/drivers/taitowlf.c b/src/mame/drivers/taitowlf.c index 18c4d253bae..6c73fc7f144 100644 --- a/src/mame/drivers/taitowlf.c +++ b/src/mame/drivers/taitowlf.c @@ -386,7 +386,7 @@ static DMA8237_MEM_WRITE( pc_dma_write_byte ) static const struct dma8237_interface dma8237_1_config = { - 0, + "main", 1.0e-6, // 1us pc_dma_read_byte, @@ -400,7 +400,7 @@ static const struct dma8237_interface dma8237_1_config = static const struct dma8237_interface dma8237_2_config = { - 0, + "main", 1.0e-6, // 1us NULL, diff --git a/src/mame/drivers/toypop.c b/src/mame/drivers/toypop.c index 1dae945ecb5..4ef81879b66 100644 --- a/src/mame/drivers/toypop.c +++ b/src/mame/drivers/toypop.c @@ -154,30 +154,30 @@ static WRITE16_HANDLER( toypop_m68000_sharedram_w ) static READ8_HANDLER( toypop_main_interrupt_enable_r ) { - cpu_interrupt_enable(0,1); + cpu_interrupt_enable(space->machine->cpu[0],1); return 0; } static WRITE8_HANDLER( toypop_main_interrupt_enable_w ) { - cpu_interrupt_enable(0,1); + cpu_interrupt_enable(space->machine->cpu[0],1); cpu_set_input_line(space->machine->cpu[0], 0, CLEAR_LINE); } static WRITE8_HANDLER( toypop_main_interrupt_disable_w ) { - cpu_interrupt_enable(0,0); + cpu_interrupt_enable(space->machine->cpu[0],0); } static WRITE8_HANDLER( toypop_sound_interrupt_enable_acknowledge_w ) { - cpu_interrupt_enable(1,1); + cpu_interrupt_enable(space->machine->cpu[1],1); cpu_set_input_line(space->machine->cpu[1], 0, CLEAR_LINE); } static WRITE8_HANDLER( toypop_sound_interrupt_disable_w ) { - cpu_interrupt_enable(1,0); + cpu_interrupt_enable(space->machine->cpu[1],0); } static INTERRUPT_GEN( toypop_main_interrupt ) @@ -212,9 +212,9 @@ static WRITE8_HANDLER( toypop_m68000_assert_w ) static TIMER_CALLBACK( disable_interrupts ) { - cpu_interrupt_enable(0,0); + cpu_interrupt_enable(machine->cpu[0],0); cpu_set_input_line(machine->cpu[0], 0, CLEAR_LINE); - cpu_interrupt_enable(1,0); + cpu_interrupt_enable(machine->cpu[1],0); cpu_set_input_line(machine->cpu[1], 0, CLEAR_LINE); interrupt_enable_68k = 0; } diff --git a/src/mame/drivers/warpwarp.c b/src/mame/drivers/warpwarp.c index bc06430572d..cfb0c8107b1 100644 --- a/src/mame/drivers/warpwarp.c +++ b/src/mame/drivers/warpwarp.c @@ -288,7 +288,7 @@ static WRITE8_HANDLER( warpwarp_out3_w ) break; case 6: warpwarp_ball_on = data & 1; - cpu_interrupt_enable(0,data & 1); + cpu_interrupt_enable(space->machine->cpu[0],data & 1); if (~data & 1) cpu_set_input_line(space->machine->cpu[0], 0, CLEAR_LINE); break; diff --git a/src/mame/drivers/xybots.c b/src/mame/drivers/xybots.c index 3d775448de1..84423fd62c2 100644 --- a/src/mame/drivers/xybots.c +++ b/src/mame/drivers/xybots.c @@ -383,7 +383,7 @@ ROM_END static DRIVER_INIT( xybots ) { atarigen_eeprom_default = NULL; - atarigen_slapstic_init(machine, 0, 0x008000, 0, 107); + atarigen_slapstic_init(machine->cpu[0], 0x008000, 0, 107); atarijsa_init(machine, "FFE200", 0x0100); } diff --git a/src/mame/machine/atarigen.c b/src/mame/machine/atarigen.c index e195f2d783d..952a23dd0e1 100644 --- a/src/mame/machine/atarigen.c +++ b/src/mame/machine/atarigen.c @@ -535,7 +535,7 @@ static DIRECT_UPDATE_HANDLER( atarigen_slapstic_setdirect ) slapstic and sets the chip number. ---------------------------------------------------------------*/ -void atarigen_slapstic_init(running_machine *machine, int cpunum, offs_t base, offs_t mirror, int chipnum) +void atarigen_slapstic_init(const device_config *device, offs_t base, offs_t mirror, int chipnum) { /* reset in case we have no state */ atarigen_slapstic_num = chipnum; @@ -545,10 +545,10 @@ void atarigen_slapstic_init(running_machine *machine, int cpunum, offs_t base, o if (chipnum != 0) { /* initialize the slapstic */ - slapstic_init(machine, chipnum); + slapstic_init(device->machine, chipnum); /* install the memory handlers */ - atarigen_slapstic = memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[cpunum], ADDRESS_SPACE_PROGRAM), base, base + 0x7fff, 0, mirror, atarigen_slapstic_r, atarigen_slapstic_w); + atarigen_slapstic = memory_install_readwrite16_handler(cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM), base, base + 0x7fff, 0, mirror, atarigen_slapstic_r, atarigen_slapstic_w); /* allocate memory for a copy of bank 0 */ atarigen_slapstic_bank0 = auto_malloc(0x2000); @@ -560,7 +560,7 @@ void atarigen_slapstic_init(running_machine *machine, int cpunum, offs_t base, o /* install an opcode base handler if we are a 68000 or variant */ atarigen_slapstic_base = base; atarigen_slapstic_mirror = mirror; - memory_set_direct_update_handler(cpu_get_address_space(machine->cpu[cpunum], ADDRESS_SPACE_PROGRAM), atarigen_slapstic_setdirect); + memory_set_direct_update_handler(cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM), atarigen_slapstic_setdirect); } } diff --git a/src/mame/machine/atarigen.h b/src/mame/machine/atarigen.h index b608282b5cf..3b52dee7927 100644 --- a/src/mame/machine/atarigen.h +++ b/src/mame/machine/atarigen.h @@ -134,7 +134,7 @@ NVRAM_HANDLER( atarigen ); SLAPSTIC HANDLING ---------------------------------------------------------------*/ -void atarigen_slapstic_init(running_machine *machine, int cpunum, offs_t base, offs_t mirror, int chipnum); +void atarigen_slapstic_init(const device_config *device, offs_t base, offs_t mirror, int chipnum); void atarigen_slapstic_reset(void); WRITE16_HANDLER( atarigen_slapstic_w ); diff --git a/src/mame/machine/bublbobl.c b/src/mame/machine/bublbobl.c index 80ad96e126f..9f1401a7656 100644 --- a/src/mame/machine/bublbobl.c +++ b/src/mame/machine/bublbobl.c @@ -27,7 +27,7 @@ WRITE8_HANDLER( bublbobl_bankswitch_w ) cpu_set_input_line(space->machine->cpu[1], INPUT_LINE_RESET, (data & 0x10) ? CLEAR_LINE : ASSERT_LINE); /* bit 5 resets mcu */ - if (space->machine->config->cpu[3].type != CPU_DUMMY) // only if we have a MCU + if (space->machine->cpu[3] != NULL) // only if we have a MCU cpu_set_input_line(space->machine->cpu[3], INPUT_LINE_RESET, (data & 0x20) ? CLEAR_LINE : ASSERT_LINE); /* bit 6 enables display */ diff --git a/src/mame/machine/leland.c b/src/mame/machine/leland.c index 2e80d51b842..118b502f9c8 100644 --- a/src/mame/machine/leland.c +++ b/src/mame/machine/leland.c @@ -409,7 +409,7 @@ MACHINE_RESET( leland ) memory_set_bankptr(machine, 3, &slave_base[0x10000]); /* if we have an I80186 CPU, reset it */ - if (machine->config->cpu[2].type == CPU_I80186) + if (cpu_get_type(machine->cpu[2]) == CPU_I80186) leland_80186_sound_init(); } diff --git a/src/mame/machine/mexico86.c b/src/mame/machine/mexico86.c index 3bcbd58e8f2..43f989bfaff 100644 --- a/src/mame/machine/mexico86.c +++ b/src/mame/machine/mexico86.c @@ -23,7 +23,7 @@ bit 0 = ? (unused?) WRITE8_HANDLER( mexico86_f008_w ) { cpu_set_input_line(space->machine->cpu[1], INPUT_LINE_RESET, (data & 4) ? CLEAR_LINE : ASSERT_LINE); - if (space->machine->config->cpu[2].type != CPU_DUMMY) + if (space->machine->cpu[2] != NULL) { // mexico 86, knight boy cpu_set_input_line(space->machine->cpu[2], INPUT_LINE_RESET, (data & 2) ? CLEAR_LINE : ASSERT_LINE); diff --git a/src/mame/machine/namcos1.c b/src/mame/machine/namcos1.c index 29fae706b97..c7ca56391b5 100644 --- a/src/mame/machine/namcos1.c +++ b/src/mame/machine/namcos1.c @@ -681,8 +681,8 @@ static WRITE8_HANDLER( unknown_w ) /* Main bankswitching routine */ static void set_bank(running_machine *machine, int banknum, const bankhandler *handler) { + const address_space *space = cpu_get_address_space(machine->cpu[(banknum >> 3) & 1], ADDRESS_SPACE_PROGRAM); int bankstart = (banknum & 7) * 0x2000; - int cpunum = (banknum >> 3) & 1; /* for BANK handlers , memory direct and OP-code base */ if (handler->bank_pointer) @@ -692,12 +692,12 @@ static void set_bank(running_machine *machine, int banknum, const bankhandler *h if (!handler->bank_handler_r) { if (namcos1_active_bank[banknum].bank_handler_r) - memory_install_read8_handler(cpu_get_address_space(machine->cpu[cpunum], ADDRESS_SPACE_PROGRAM), bankstart, bankstart + 0x1fff, 0, 0, ram_bank_handler_r[banknum]); + memory_install_read8_handler(space, bankstart, bankstart + 0x1fff, 0, 0, ram_bank_handler_r[banknum]); } else { if (!namcos1_active_bank[banknum].bank_handler_r) - memory_install_read8_handler(cpu_get_address_space(machine->cpu[cpunum], ADDRESS_SPACE_PROGRAM), bankstart, bankstart + 0x1fff, 0, 0, io_bank_handler_r[banknum]); + memory_install_read8_handler(space, bankstart, bankstart + 0x1fff, 0, 0, io_bank_handler_r[banknum]); } /* write handlers (except for the 0xe000-0xffff range) */ @@ -706,12 +706,12 @@ static void set_bank(running_machine *machine, int banknum, const bankhandler *h if (!handler->bank_handler_w) { if (namcos1_active_bank[banknum].bank_handler_w) - memory_install_write8_handler(cpu_get_address_space(machine->cpu[cpunum], ADDRESS_SPACE_PROGRAM), bankstart, bankstart + 0x1fff, 0, 0, ram_bank_handler_w[banknum]); + memory_install_write8_handler(space, bankstart, bankstart + 0x1fff, 0, 0, ram_bank_handler_w[banknum]); } else { if (!namcos1_active_bank[banknum].bank_handler_r) - memory_install_write8_handler(cpu_get_address_space(machine->cpu[cpunum], ADDRESS_SPACE_PROGRAM), bankstart, bankstart + 0x1fff, 0, 0, io_bank_handler_w[banknum]); + memory_install_write8_handler(space, bankstart, bankstart + 0x1fff, 0, 0, io_bank_handler_w[banknum]); } } diff --git a/src/mame/machine/segaic16.c b/src/mame/machine/segaic16.c index a4ec8b7a9eb..6ddb454c920 100644 --- a/src/mame/machine/segaic16.c +++ b/src/mame/machine/segaic16.c @@ -325,7 +325,7 @@ static void update_memory_mapping(running_machine *machine, struct memory_mapper if (LOG_MEMORY_MAP) mame_printf_debug("----\nRemapping:\n"); /* first reset everything back to the beginning */ - memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[cpu_get_index(chip->cpu)], ADDRESS_SPACE_PROGRAM), 0x000000, 0xffffff, 0, 0, segaic16_memory_mapper_lsb_r, segaic16_memory_mapper_lsb_w); + memory_install_readwrite16_handler(cpu_get_address_space(chip->cpu, ADDRESS_SPACE_PROGRAM), 0x000000, 0xffffff, 0, 0, segaic16_memory_mapper_lsb_r, segaic16_memory_mapper_lsb_w); /* loop over the regions */ for (rgnum = 0; chip->map[rgnum].regbase != 0; rgnum++) diff --git a/src/mame/machine/slapstic.c b/src/mame/machine/slapstic.c index 5698b2c68bd..e888beb4eae 100644 --- a/src/mame/machine/slapstic.c +++ b/src/mame/machine/slapstic.c @@ -806,6 +806,8 @@ static FILE *slapsticlog; void slapstic_init(running_machine *machine, int chip) { + cpu_type cputype = cpu_get_type(machine->cpu[0]); + /* only a small number of chips are known to exist */ if (chip < 101 || chip > 118) return; @@ -819,8 +821,7 @@ void slapstic_init(running_machine *machine, int chip) slapstic_reset(); /* see if we're 68k or 6502/6809 based */ - access_68k = (machine->config->cpu[0].type == CPU_M68000 || - machine->config->cpu[0].type == CPU_M68010); + access_68k = (cputype == CPU_M68000 || cputype == CPU_M68010); /* save state */ state_save_register_item(machine, "slapstic", NULL, 0, state); diff --git a/src/mame/machine/taitosj.c b/src/mame/machine/taitosj.c index e97e08ccc1f..1fb4566d22f 100644 --- a/src/mame/machine/taitosj.c +++ b/src/mame/machine/taitosj.c @@ -53,8 +53,8 @@ MACHINE_RESET( taitosj ) zaccept = 1; zready = 0; busreq = 0; - if (machine->config->cpu[2].type != CPU_DUMMY) - cpu_set_input_line(machine->cpu[2],0,CLEAR_LINE); + if (machine->cpu[2] != NULL) + cpu_set_input_line(machine->cpu[2],0,CLEAR_LINE); spacecr_prot_value = 0; } diff --git a/src/mame/machine/tnzs.c b/src/mame/machine/tnzs.c index 3f5e5ed355f..7577a2ee7de 100644 --- a/src/mame/machine/tnzs.c +++ b/src/mame/machine/tnzs.c @@ -713,7 +713,7 @@ WRITE8_HANDLER( tnzs_bankswitch1_w ) /* bit 2 resets the mcu */ if (data & 0x04) { - if (space->machine->config->cpu[2].type == CPU_I8742) + if (space->machine->cpu[2] != NULL && cpu_get_type(space->machine->cpu[2]) == CPU_I8742) cpu_set_input_line(space->machine->cpu[2], INPUT_LINE_RESET, PULSE_LINE); } /* Coin count and lockout is handled by the i8742 */ diff --git a/src/mame/machine/toaplan1.c b/src/mame/machine/toaplan1.c index b5beda41cdc..2fc02701acc 100644 --- a/src/mame/machine/toaplan1.c +++ b/src/mame/machine/toaplan1.c @@ -232,7 +232,7 @@ WRITE16_HANDLER( toaplan1_reset_sound ) logerror("PC:%04x Resetting Sound CPU and Sound chip (%08x)\n",cpu_get_previouspc(space->cpu),data); if (space->machine->config->sound[0].type == SOUND_YM3812) sndti_reset(SOUND_YM3812, 0); - if (space->machine->config->cpu[1].type == CPU_Z80) + if (space->machine->cpu[1] != NULL && cpu_get_type(space->machine->cpu[1]) == CPU_Z80) cpu_set_input_line(space->machine->cpu[1], INPUT_LINE_RESET, PULSE_LINE); } } diff --git a/src/mame/video/taitoic.c b/src/mame/video/taitoic.c index bde3e7f2131..6e076127245 100644 --- a/src/mame/video/taitoic.c +++ b/src/mame/video/taitoic.c @@ -577,9 +577,8 @@ INLINE void taitoic_drawscanline( /* Note: various assumptions are made in these routines, typically that only CPU#0 is of interest. If in doubt, check the routine. */ -static int has_write_handler(running_machine *machine, int cpunum, write16_space_func handler) +static int has_write_handler(const device_config *cpu, write16_space_func handler) { - const device_config *cpu = machine->cpu[cpunum]; if (cpu != NULL) { const address_space *space = cpu_get_address_space(cpu, ADDRESS_SPACE_PROGRAM); @@ -596,11 +595,11 @@ static int has_write_handler(running_machine *machine, int cpunum, write16_space int TC0100SCN_count(running_machine *machine) { - int mask = (has_write_handler(machine, 0, TC0100SCN_word_0_w) || - has_write_handler(machine, 0, TC0100SCN_dual_screen_w) || - has_write_handler(machine, 0, TC0100SCN_triple_screen_w)) ? 1 : 0; - mask |= has_write_handler(machine, 0, TC0100SCN_word_1_w) << 1; - mask |= has_write_handler(machine, 0, TC0100SCN_word_2_w) << 2; + int mask = (has_write_handler(machine->cpu[0], TC0100SCN_word_0_w) || + has_write_handler(machine->cpu[0], TC0100SCN_dual_screen_w) || + has_write_handler(machine->cpu[0], TC0100SCN_triple_screen_w)) ? 1 : 0; + mask |= has_write_handler(machine->cpu[0], TC0100SCN_word_1_w) << 1; + mask |= has_write_handler(machine->cpu[0], TC0100SCN_word_2_w) << 2; /* Catch illegal configurations */ /* TODO: we should give an appropriate warning */ @@ -611,45 +610,45 @@ int TC0100SCN_count(running_machine *machine) int TC0110PCR_mask(running_machine *machine) { - int mask = (has_write_handler(machine, 0, TC0110PCR_word_w) || - has_write_handler(machine, 0, TC0110PCR_step1_word_w) || - has_write_handler(machine, 0, TC0110PCR_step1_rbswap_word_w) || - has_write_handler(machine, 0, TC0110PCR_step1_4bpg_word_w)) ? 1 : 0; - mask |= has_write_handler(machine, 0, TC0110PCR_step1_word_1_w) << 1; - mask |= has_write_handler(machine, 0, TC0110PCR_step1_word_2_w) << 2; + int mask = (has_write_handler(machine->cpu[0], TC0110PCR_word_w) || + has_write_handler(machine->cpu[0], TC0110PCR_step1_word_w) || + has_write_handler(machine->cpu[0], TC0110PCR_step1_rbswap_word_w) || + has_write_handler(machine->cpu[0], TC0110PCR_step1_4bpg_word_w)) ? 1 : 0; + mask |= has_write_handler(machine->cpu[0], TC0110PCR_step1_word_1_w) << 1; + mask |= has_write_handler(machine->cpu[0], TC0110PCR_step1_word_2_w) << 2; return mask; } int has_TC0150ROD(running_machine *machine) { - return has_write_handler(machine, 0, TC0150ROD_word_w) || - has_write_handler(machine, 1, TC0150ROD_word_w) || - has_write_handler(machine, 2, TC0150ROD_word_w); + return has_write_handler(machine->cpu[0], TC0150ROD_word_w) || + has_write_handler(machine->cpu[1], TC0150ROD_word_w) || + has_write_handler(machine->cpu[2], TC0150ROD_word_w); } int has_TC0280GRD(running_machine *machine) { - return has_write_handler(machine, 0, TC0280GRD_word_w); + return has_write_handler(machine->cpu[0], TC0280GRD_word_w); } int has_TC0360PRI(running_machine *machine) { - return has_write_handler(machine, 0, TC0360PRI_halfword_w) || - has_write_handler(machine, 0, TC0360PRI_halfword_swap_w); + return has_write_handler(machine->cpu[0], TC0360PRI_halfword_w) || + has_write_handler(machine->cpu[0], TC0360PRI_halfword_swap_w); } int has_TC0430GRW(running_machine *machine) { - return has_write_handler(machine, 0, TC0430GRW_word_w); + return has_write_handler(machine->cpu[0], TC0430GRW_word_w); } int has_TC0480SCP(running_machine *machine) { - return has_write_handler(machine, 0, TC0480SCP_word_w); + return has_write_handler(machine->cpu[0], TC0480SCP_word_w); }