diff options
author | 2009-09-08 09:13:10 +0000 | |
---|---|---|
committer | 2009-09-08 09:13:10 +0000 | |
commit | 96d7f2cf3b9f7065f834ab81e190e66818f83e29 (patch) | |
tree | f5a9d8996be6d41836e9754cd4b443b88dfb773c | |
parent | 3d59122bb25c14f275227ed6cd4fcfb24d15f92b (diff) |
Remove remaining references to machine->cpu[n]. Removed cpu[n] array.
Replaced with machine->firstcpu which is a fast access to the head
of the list of CPUs.
-rw-r--r-- | src/emu/cpu/m6502/m6502.h | 2 | ||||
-rw-r--r-- | src/emu/cpu/m6502/m6509.h | 2 | ||||
-rw-r--r-- | src/emu/cpu/pdp1/pdp1.c | 2 | ||||
-rw-r--r-- | src/emu/cpu/pdp1/pdp1.h | 4 | ||||
-rw-r--r-- | src/emu/cpu/pdp1/tx0.h | 4 | ||||
-rw-r--r-- | src/emu/cpu/tms34010/tms34010.c | 2 | ||||
-rw-r--r-- | src/emu/cpuexec.c | 19 | ||||
-rw-r--r-- | src/emu/debug/debugcmd.c | 40 | ||||
-rw-r--r-- | src/emu/debug/debugcmt.c | 279 | ||||
-rw-r--r-- | src/emu/debug/debugcpu.c | 26 | ||||
-rw-r--r-- | src/emu/debug/debugcpu.h | 2 | ||||
-rw-r--r-- | src/emu/debug/debugvw.c | 10 | ||||
-rw-r--r-- | src/emu/machine/6522via.c | 2 | ||||
-rw-r--r-- | src/emu/machine/8042kbdc.c | 2 | ||||
-rw-r--r-- | src/emu/machine/generic.c | 89 | ||||
-rw-r--r-- | src/emu/machine/latch8.c | 2 | ||||
-rw-r--r-- | src/emu/machine/tmp68301.c | 8 | ||||
-rw-r--r-- | src/emu/mame.c | 7 | ||||
-rw-r--r-- | src/emu/mame.h | 2 | ||||
-rw-r--r-- | src/emu/sound/scsp.c | 8 | ||||
-rw-r--r-- | src/emu/ui.c | 24 | ||||
-rw-r--r-- | src/mame/machine/atarigen.c | 15 | ||||
-rw-r--r-- | src/mame/video/avgdvg.c | 2 | ||||
-rw-r--r-- | src/mame/video/system1.c | 4 |
24 files changed, 270 insertions, 287 deletions
diff --git a/src/emu/cpu/m6502/m6502.h b/src/emu/cpu/m6502/m6502.h index aac21d37cc5..5fc4dfd5ad7 100644 --- a/src/emu/cpu/m6502/m6502.h +++ b/src/emu/cpu/m6502/m6502.h @@ -47,7 +47,7 @@ enum }; #define M6502_IRQ_LINE 0 -/* use cpu_set_input_line(machine->cpu[cpu], M6502_SET_OVERFLOW, level) +/* use cpu_set_input_line(cpudevice, M6502_SET_OVERFLOW, level) to change level of the so input line positiv edge sets overflow flag */ #define M6502_SET_OVERFLOW 1 diff --git a/src/emu/cpu/m6502/m6509.h b/src/emu/cpu/m6502/m6509.h index 0ff2dc546b4..f0b305441e0 100644 --- a/src/emu/cpu/m6502/m6509.h +++ b/src/emu/cpu/m6502/m6509.h @@ -34,7 +34,7 @@ enum }; #define M6509_IRQ_LINE M6502_IRQ_LINE -/* use cpu_set_input_line(machine->cpu[cpu], M6509_SET_OVERFLOW, level) +/* use cpu_set_input_line(cpudevice, M6509_SET_OVERFLOW, level) to change level of the so input line positiv edge sets overflow flag */ #define M6509_SET_OVERFLOW 3 diff --git a/src/emu/cpu/pdp1/pdp1.c b/src/emu/cpu/pdp1/pdp1.c index b9872c74e90..adcb5cfa4ab 100644 --- a/src/emu/cpu/pdp1/pdp1.c +++ b/src/emu/cpu/pdp1/pdp1.c @@ -1711,7 +1711,7 @@ static void null_iot(const device_config *device, int op2, int nac, int mb, int if (LOG_IOT_EXTRA) { if (op2 == 000) - logerror("IOT sync instruction: mb=0%06o, pc=0%06o\n", (unsigned) mb, (unsigned) cpu_get_reg(device->machine->cpu[0], PDP1_PC)); + logerror("IOT sync instruction: mb=0%06o, pc=0%06o\n", (unsigned) mb, (unsigned) cpu_get_reg(device, PDP1_PC)); } if (LOG) { diff --git a/src/emu/cpu/pdp1/pdp1.h b/src/emu/cpu/pdp1/pdp1.h index c5557914267..1a33984bc51 100644 --- a/src/emu/cpu/pdp1/pdp1.h +++ b/src/emu/cpu/pdp1/pdp1.h @@ -20,8 +20,8 @@ enum PDP1_IO_COMPLETE /* hack, do not use directly, use pdp1_pulse_iot_done instead */ }; -#define pdp1_pulse_start_clear() cpu_set_reg(machine->cpu[0], PDP1_START_CLEAR, 0) -#define pdp1_pulse_iot_done() cpu_set_reg(machine->cpu[0], PDP1_IO_COMPLETE, 0) +#define pdp1_pulse_start_clear(cpudevice) cpu_set_reg(cpudevice, PDP1_START_CLEAR, 0) +#define pdp1_pulse_iot_done(cpudevice) cpu_set_reg(cpudevice, PDP1_IO_COMPLETE, 0) typedef void (*pdp1_extern_iot_func)(const device_config *device, int op2, int nac, int mb, int *io, int ac); typedef void (*pdp1_read_binary_word_func)(const device_config *device); diff --git a/src/emu/cpu/pdp1/tx0.h b/src/emu/cpu/pdp1/tx0.h index ee3989cf8ff..1db1fc64932 100644 --- a/src/emu/cpu/pdp1/tx0.h +++ b/src/emu/cpu/pdp1/tx0.h @@ -21,8 +21,8 @@ enum TX0_IO_COMPLETE /* hack, do not use directly, use tx0_pulse_io_complete instead */ }; -#define tx0_pulse_reset() cpu_set_reg(machine->cpu[0], TX0_RESET, 0) -#define tx0_pulse_io_complete() cpu_set_reg(machine->cpu[0], TX0_IO_COMPLETE, 0) +#define tx0_pulse_reset(cpudevice) cpu_set_reg(cpudevice, TX0_RESET, 0) +#define tx0_pulse_io_complete(cpudevice) cpu_set_reg(cpudevice, TX0_IO_COMPLETE, 0) typedef struct _tx0_reset_param_t tx0_reset_param_t; struct _tx0_reset_param_t diff --git a/src/emu/cpu/tms34010/tms34010.c b/src/emu/cpu/tms34010/tms34010.c index c5aac6e6b6c..2a17c72f9af 100644 --- a/src/emu/cpu/tms34010/tms34010.c +++ b/src/emu/cpu/tms34010/tms34010.c @@ -1139,7 +1139,7 @@ VIDEO_UPDATE( tms340x0 ) int x; /* find the owning CPU */ - for (cpu = screen->machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = screen->machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { cpu_type type = cpu_get_type(cpu); if (type == CPU_TMS34010 || type == CPU_TMS34020) diff --git a/src/emu/cpuexec.c b/src/emu/cpuexec.c index 0f55997ad5f..ad23be68939 100644 --- a/src/emu/cpuexec.c +++ b/src/emu/cpuexec.c @@ -460,10 +460,6 @@ static DEVICE_START( cpu ) header = cpu_get_class_header(device); classdata = 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; header->set_info = (cpu_set_info_func)device_get_info_fct(device, CPUINFO_FCT_SET_INFO); @@ -1113,7 +1109,7 @@ void cpuexec_trigger(running_machine *machine, int trigger) const device_config *cpu; /* look for suspended CPUs waiting for this trigger and unsuspend them */ - for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { cpu_class_data *classdata = get_class_data(cpu); @@ -1306,14 +1302,15 @@ static void update_clock_information(const device_config *device) static void compute_perfect_interleave(running_machine *machine) { - if (machine->cpu[0] != NULL) + const device_config *firstcpu = machine->firstcpu; + if (firstcpu != NULL) { - attoseconds_t smallest = get_minimum_quantum(machine->cpu[0]); + attoseconds_t smallest = get_minimum_quantum(firstcpu); attoseconds_t perfect = ATTOSECONDS_PER_SECOND - 1; const device_config *cpu; /* start with a huge time factor and find the 2nd smallest cycle time */ - for (cpu = machine->cpu[0]->typenext; cpu != NULL; cpu = cpu->typenext) + for (cpu = cpu_next(firstcpu); cpu != NULL; cpu = cpu_next(cpu)) { attoseconds_t curquantum = get_minimum_quantum(cpu); @@ -1348,7 +1345,7 @@ static void on_vblank(const device_config *device, void *param, int vblank_state const device_config *cpu; /* find any CPUs that have this screen as their VBLANK interrupt source */ - for (cpu = device->machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = device->machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { const cpu_config *config = (const cpu_config *)cpu->inline_config; cpu_class_data *classdata = get_class_data(cpu); @@ -1616,7 +1613,7 @@ static void rebuild_execute_list(running_machine *machine) *tailptr = NULL; /* first iterate over non-suspended CPUs */ - for (curcpu = machine->cpu[0]; curcpu != NULL; curcpu = curcpu->typenext) + for (curcpu = machine->firstcpu; curcpu != NULL; curcpu = cpu_next(curcpu)) { cpu_class_data *classdata = get_class_data(curcpu); if (classdata->suspend == 0) @@ -1628,7 +1625,7 @@ static void rebuild_execute_list(running_machine *machine) } /* then add the suspended CPUs */ - for (curcpu = machine->cpu[0]; curcpu != NULL; curcpu = curcpu->typenext) + for (curcpu = machine->firstcpu; curcpu != NULL; curcpu = cpu_next(curcpu)) { cpu_class_data *classdata = get_class_data(curcpu); if (classdata->suspend != 0) diff --git a/src/emu/debug/debugcmd.c b/src/emu/debug/debugcmd.c index 31989f72c70..bc2a261a4df 100644 --- a/src/emu/debug/debugcmd.c +++ b/src/emu/debug/debugcmd.c @@ -335,7 +335,7 @@ 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 (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { cpu_debug_init_func debug_init; debug_init = (cpu_debug_init_func)device_get_info_fct(cpu, CPUINFO_FCT_DEBUG_INIT); @@ -361,7 +361,7 @@ static void debug_command_exit(running_machine *machine) const device_config *cpu; /* turn off all traces */ - for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) debug_cpu_trace(cpu, NULL, 0, NULL); if (cheat.length) @@ -510,14 +510,14 @@ int debug_command_parameter_cpu(running_machine *machine, const char *param, con return FALSE; } + /* if we got a valid one, return */ + *result = device_list_find_by_index(machine->config->devicelist, CPU, cpunum); + if (*result != NULL) + return TRUE; + /* if out of range, complain */ - if (cpunum >= ARRAY_LENGTH(machine->cpu) || machine->cpu[cpunum] == NULL) - { - debug_console_printf(machine, "Invalid CPU index %d\n", (UINT32)cpunum); - return FALSE; - } - *result = machine->cpu[cpunum]; - return TRUE; + debug_console_printf(machine, "Invalid CPU index %d\n", (UINT32)cpunum); + return FALSE; } @@ -957,7 +957,7 @@ 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 (scancpu = machine->cpu[0]; scancpu != NULL; scancpu = scancpu->typenext) + for (scancpu = machine->firstcpu; scancpu != NULL; scancpu = cpu_next(scancpu)) if (scancpu != cpu) debug_cpu_ignore_cpu(scancpu, 1); debug_console_printf(machine, "Now focused on CPU '%s'\n", cpu->tag); @@ -980,7 +980,7 @@ static void execute_ignore(running_machine *machine, int ref, int params, const if (params == 0) { /* loop over all CPUs */ - for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); @@ -1012,7 +1012,7 @@ 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 (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) if (cpu != cpuwhich[paramnum] && (cpu_get_debug_data(cpu)->flags & DEBUG_FLAG_OBSERVING) != 0) break; if (cpu == NULL) @@ -1044,7 +1044,7 @@ static void execute_observe(running_machine *machine, int ref, int params, const if (params == 0) { /* loop over all CPUs */ - for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); @@ -1196,7 +1196,7 @@ static void execute_bpclear(running_machine *machine, int ref, int params, const { const device_config *cpu; - for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); debug_cpu_breakpoint *bp; @@ -1234,7 +1234,7 @@ static void execute_bpdisenable(running_machine *machine, int ref, int params, c { const device_config *cpu; - for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); debug_cpu_breakpoint *bp; @@ -1273,7 +1273,7 @@ static void execute_bplist(running_machine *machine, int ref, int params, const char buffer[256]; /* loop over all CPUs */ - for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); @@ -1370,7 +1370,7 @@ static void execute_wpclear(running_machine *machine, int ref, int params, const { const device_config *cpu; - for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); int spacenum; @@ -1413,7 +1413,7 @@ static void execute_wpdisenable(running_machine *machine, int ref, int params, c { const device_config *cpu; - for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); int spacenum; @@ -1457,7 +1457,7 @@ static void execute_wplist(running_machine *machine, int ref, int params, const char buffer[256]; /* loop over all CPUs */ - for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); int spacenum; @@ -1509,7 +1509,7 @@ static void execute_hotspot(running_machine *machine, int ref, int params, const int cleared = FALSE; /* loop over CPUs and find live spots */ - for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); diff --git a/src/emu/debug/debugcmt.c b/src/emu/debug/debugcmt.c index 4db231cce50..6cb5a537f8e 100644 --- a/src/emu/debug/debugcmt.c +++ b/src/emu/debug/debugcmt.c @@ -54,32 +54,25 @@ typedef struct _debug_comment debug_comment; struct _debug_comment { - UINT8 is_valid; - UINT32 address; - char text[DEBUG_COMMENT_MAX_LINE_LENGTH]; - rgb_t color; - UINT32 crc; + UINT8 is_valid; + UINT32 address; + char text[DEBUG_COMMENT_MAX_LINE_LENGTH]; + rgb_t color; + UINT32 crc; }; -typedef struct _comment_group comment_group; -struct _comment_group + +/* in debugcpu.h -- typedef struct _debug_cpu_comment_group debug_cpu_comment_group; */ +struct _debug_cpu_comment_group { - int comment_count; - UINT32 change_count; - debug_comment *comment_info[DEBUG_COMMENT_MAX_NUM]; + int comment_count; + UINT32 change_count; + debug_comment * comment_info[DEBUG_COMMENT_MAX_NUM]; }; /*************************************************************************** - GLOBAL VARIABLES -***************************************************************************/ - -static comment_group *debug_comments; - - - -/*************************************************************************** FUNCTION PROTOTYPES ***************************************************************************/ @@ -90,9 +83,7 @@ static void debug_comment_free(running_machine *machine); /*************************************************************************** - - Initialization - + INITIALIZATION ***************************************************************************/ /*------------------------------------------------------------------------- @@ -102,22 +93,18 @@ static void debug_comment_free(running_machine *machine); int debug_comment_init(running_machine *machine) { - int numcpu; - - for (numcpu = 0; numcpu < ARRAY_LENGTH(machine->cpu); numcpu++) - if (machine->cpu[numcpu] == NULL) - break; - if (numcpu > 0) + const device_config *cpu; + + /* allocate memory for the comments */ + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { - /* allocate enough comment groups for the total # of cpu's */ - debug_comments = auto_alloc_array_clear(machine, comment_group, numcpu); - - /* automatically load em up */ - debug_comment_load(machine); - - add_exit_callback(machine, debug_comment_exit); + cpu_debug_data *cpudata = cpu_get_debug_data(cpu); + cpudata->comments = auto_alloc(machine, debug_cpu_comment_group); } + /* automatically load em up */ + debug_comment_load(machine); + add_exit_callback(machine, debug_comment_exit); return 1; } @@ -130,10 +117,10 @@ int debug_comment_init(running_machine *machine) int debug_comment_add(const device_config *device, offs_t addr, const char *comment, rgb_t color, UINT32 c_crc) { - int cpu_num = cpu_get_index(device); - int i = 0; - int insert_point = debug_comments[cpu_num].comment_count; + debug_cpu_comment_group *comments = cpu_get_debug_data(device)->comments; + int insert_point = comments->comment_count; int match = 0; + int i = 0; /* Create a new item to insert into the list */ debug_comment *insert_me = alloc_or_die(debug_comment); @@ -144,15 +131,15 @@ int debug_comment_add(const device_config *device, offs_t addr, const char *comm strcpy(insert_me->text, comment); /* Find the insert point */ - for (i = 0; i < debug_comments[cpu_num].comment_count; i++) + for (i = 0; i < comments->comment_count; i++) { - if (insert_me->address < debug_comments[cpu_num].comment_info[i]->address) + if (insert_me->address < comments->comment_info[i]->address) { insert_point = i; break; } - else if (insert_me->address == debug_comments[cpu_num].comment_info[i]->address && - insert_me->crc == debug_comments[cpu_num].comment_info[i]->crc) + else if (insert_me->address == comments->comment_info[i]->address && + insert_me->crc == comments->comment_info[i]->crc) { insert_point = i; match = 1; @@ -163,9 +150,9 @@ int debug_comment_add(const device_config *device, offs_t addr, const char *comm /* Got an exact match? Just replace */ if (match == 1) { - free(debug_comments[cpu_num].comment_info[insert_point]); - debug_comments[cpu_num].comment_info[insert_point] = insert_me; - debug_comments[cpu_num].change_count++; + free(comments->comment_info[insert_point]); + comments->comment_info[insert_point] = insert_me; + comments->change_count++; /* force an update of disassembly views */ debug_view_update_type(device->machine, DVT_DISASSEMBLY); @@ -174,13 +161,13 @@ int debug_comment_add(const device_config *device, offs_t addr, const char *comm /* Otherwise insert */ /* First, shift the list down */ - for (i = debug_comments[cpu_num].comment_count; i >= insert_point; i--) - debug_comments[cpu_num].comment_info[i] = debug_comments[cpu_num].comment_info[i-1]; + for (i = comments->comment_count; i >= insert_point; i--) + comments->comment_info[i] = comments->comment_info[i-1]; /* do the insertion */ - debug_comments[cpu_num].comment_info[insert_point] = insert_me; - debug_comments[cpu_num].comment_count++; - debug_comments[cpu_num].change_count++; + comments->comment_info[insert_point] = insert_me; + comments->comment_count++; + comments->change_count++; /* force an update of disassembly views */ debug_view_update_type(device->machine, DVT_DISASSEMBLY); @@ -197,35 +184,27 @@ int debug_comment_add(const device_config *device, offs_t addr, const char *comm int debug_comment_remove(const device_config *device, offs_t addr, UINT32 c_crc) { - int cpu_num = cpu_get_index(device); - int i; + debug_cpu_comment_group *comments = cpu_get_debug_data(device)->comments; int remove_index = -1; + int i; - for (i = 0; i < debug_comments[cpu_num].comment_count; i++) - { - if (debug_comments[cpu_num].comment_info[i]->address == addr) /* got an address match */ - { - if (debug_comments[cpu_num].comment_info[i]->crc == c_crc) - { + for (i = 0; i < comments->comment_count; i++) + if (comments->comment_info[i]->address == addr) /* got an address match */ + if (comments->comment_info[i]->crc == c_crc) remove_index = i; - } - } - } /* The comment doesn't exist? */ if (remove_index == -1) return 0; /* Okay, it's there, now remove it */ - free(debug_comments[cpu_num].comment_info[remove_index]); + free(comments->comment_info[remove_index]); - for (i = remove_index; i < debug_comments[cpu_num].comment_count-1; i++) - { - debug_comments[cpu_num].comment_info[i] = debug_comments[cpu_num].comment_info[i+1]; - } + for (i = remove_index; i < comments->comment_count-1; i++) + comments->comment_info[i] = comments->comment_info[i+1]; - debug_comments[cpu_num].comment_count--; - debug_comments[cpu_num].change_count++; + comments->comment_count--; + comments->change_count++; /* force an update of disassembly views */ debug_view_update_type(device->machine, DVT_DISASSEMBLY); @@ -242,21 +221,17 @@ int debug_comment_remove(const device_config *device, offs_t addr, UINT32 c_crc) const char *debug_comment_get_text(const device_config *device, offs_t addr, UINT32 c_crc) { - int cpu_num = cpu_get_index(device); + debug_cpu_comment_group *comments = cpu_get_debug_data(device)->comments; int i; /* inefficient - should use bsearch - but will be a little tricky with multiple comments per addr */ - for (i = 0; i < debug_comments[cpu_num].comment_count; i++) - { - if (debug_comments[cpu_num].comment_info[i]->address == addr) /* got an address match */ + for (i = 0; i < comments->comment_count; i++) + if (comments->comment_info[i]->address == addr) /* got an address match */ { /* now check the bank information to be sure */ - if (debug_comments[cpu_num].comment_info[i]->crc == c_crc) - { - return debug_comments[cpu_num].comment_info[i]->text; - } + if (comments->comment_info[i]->crc == c_crc) + return comments->comment_info[i]->text; } - } return 0x00; } @@ -269,7 +244,8 @@ const char *debug_comment_get_text(const device_config *device, offs_t addr, UIN int debug_comment_get_count(const device_config *device) { - return debug_comments[cpu_get_index(device)].comment_count; + debug_cpu_comment_group *comments = cpu_get_debug_data(device)->comments; + return comments->comment_count; } @@ -280,7 +256,8 @@ int debug_comment_get_count(const device_config *device) UINT32 debug_comment_get_change_count(const device_config *device) { - return debug_comments[cpu_get_index(device)].change_count; + debug_cpu_comment_group *comments = cpu_get_debug_data(device)->comments; + return comments->change_count; } /*------------------------------------------------------------------------- @@ -290,12 +267,14 @@ UINT32 debug_comment_get_change_count(const device_config *device) UINT32 debug_comment_all_change_count(running_machine *machine) { - int i ; + const device_config *cpu; UINT32 retVal = 0; - - for (i = 0; i < ARRAY_LENGTH(machine->cpu); i++) - if (machine->cpu[i] != NULL) - retVal += debug_comments[i].change_count ; + + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) + { + debug_cpu_comment_group *comments = cpu_get_debug_data(cpu)->comments; + retVal += comments->change_count; + } return retVal; } @@ -342,41 +321,35 @@ UINT32 debug_comment_get_opcode_crc32(const device_config *device, offs_t addres void debug_comment_dump(const device_config *device, offs_t addr) { - int cpu_num = cpu_get_index(device); + debug_cpu_comment_group *comments = cpu_get_debug_data(device)->comments; int i; int ff = 0; if (addr == -1) { - for (i = 0; i < debug_comments[cpu_num].comment_count; i++) - { - if (debug_comments[cpu_num].comment_info[i]->is_valid) - { - logerror("%d : %s (%d %d)\n", i, debug_comments[cpu_num].comment_info[i]->text, - debug_comments[cpu_num].comment_info[i]->address, - debug_comments[cpu_num].comment_info[i]->crc); - } - } + for (i = 0; i < comments->comment_count; i++) + if (comments->comment_info[i]->is_valid) + logerror("%d : %s (%d %d)\n", i, comments->comment_info[i]->text, + comments->comment_info[i]->address, + comments->comment_info[i]->crc); } else { UINT32 c_crc = debug_comment_get_opcode_crc32(device, addr); - for (i = 0; i < debug_comments[cpu_num].comment_count; i++) - { - if (debug_comments[cpu_num].comment_info[i]->address == addr) /* got an address match */ + for (i = 0; i < comments->comment_count; i++) + if (comments->comment_info[i]->address == addr) /* got an address match */ { /* now check the bank information to be sure */ - if (debug_comments[cpu_num].comment_info[i]->crc == c_crc) + if (comments->comment_info[i]->crc == c_crc) { logerror("%d : %s (%d %d)\n", addr, - debug_comments[cpu_num].comment_info[addr]->text, - debug_comments[cpu_num].comment_info[addr]->address, - debug_comments[cpu_num].comment_info[addr]->crc); + comments->comment_info[addr]->text, + comments->comment_info[addr]->address, + comments->comment_info[addr]->crc); ff = 1; } } - } if (!ff) logerror("No comment exists for address : 0x%x\n", addr); } @@ -389,49 +362,51 @@ void debug_comment_dump(const device_config *device, offs_t addr) int debug_comment_save(running_machine *machine) { - int i, j; + int j; char crc_buf[20]; xml_data_node *root = xml_file_create(); xml_data_node *commentnode, *systemnode; int total_comments = 0; + const device_config *cpu; /* if we don't have a root, bail */ - if (!root) + if (root == NULL) return 0; /* create a comment node */ commentnode = xml_add_child(root, "mamecommentfile", NULL); - if (!commentnode) + if (commentnode == NULL) goto error; xml_set_attribute_int(commentnode, "version", COMMENT_VERSION); /* create a system node */ systemnode = xml_add_child(commentnode, "system", NULL); - if (!systemnode) + if (systemnode == NULL) goto error; xml_set_attribute(systemnode, "name", machine->gamedrv->name); /* for each cpu */ - for (i = 0; i < ARRAY_LENGTH(machine->cpu); i++) - if (machine->cpu[i] != NULL) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) + { + debug_cpu_comment_group *comments = cpu_get_debug_data(cpu)->comments; + + xml_data_node *curnode = xml_add_child(systemnode, "cpu", NULL); + if (curnode == NULL) + goto error; + xml_set_attribute(curnode, "tag", cpu->tag); + + for (j = 0; j < comments->comment_count; j++) { - xml_data_node *curnode = xml_add_child(systemnode, "cpu", NULL); - if (!curnode) + xml_data_node *datanode = xml_add_child(curnode, "comment", xml_normalize_string(comments->comment_info[j]->text)); + if (datanode == NULL) goto error; - xml_set_attribute_int(curnode, "num", i); - - for (j = 0; j < debug_comments[i].comment_count; j++) - { - xml_data_node *datanode = xml_add_child(curnode, "comment", xml_normalize_string(debug_comments[i].comment_info[j]->text)); - if (!datanode) - goto error; - xml_set_attribute_int(datanode, "address", debug_comments[i].comment_info[j]->address); - xml_set_attribute_int(datanode, "color", debug_comments[i].comment_info[j]->color); - sprintf(crc_buf, "%08X", debug_comments[i].comment_info[j]->crc); - xml_set_attribute(datanode, "crc", crc_buf); - total_comments++; - } + xml_set_attribute_int(datanode, "address", comments->comment_info[j]->address); + xml_set_attribute_int(datanode, "color", comments->comment_info[j]->color); + sprintf(crc_buf, "%08X", comments->comment_info[j]->crc); + xml_set_attribute(datanode, "crc", crc_buf); + total_comments++; } + } /* flush the file */ if (total_comments > 0) @@ -484,19 +459,19 @@ int debug_comment_load(running_machine *machine) static int debug_comment_load_xml(running_machine *machine, mame_file *fp) { - int i, j; + int j; xml_data_node *root, *commentnode, *systemnode, *cpunode, *datanode; const char *name; int version; /* read the file */ root = xml_file_read(mame_core_file(fp), NULL); - if (!root) + if (root == NULL) goto error; /* find the config node */ commentnode = xml_get_sibling(root->child, "mamecommentfile"); - if (!commentnode) + if (commentnode == NULL) goto error; /* validate the config data version */ @@ -510,29 +485,30 @@ static int debug_comment_load_xml(running_machine *machine, mame_file *fp) if (strcmp(name, machine->gamedrv->name) != 0) goto error; - i = 0; - for (cpunode = xml_get_sibling(systemnode->child, "cpu"); cpunode; cpunode = xml_get_sibling(cpunode->next, "cpu")) { - j = 0; - - for (datanode = xml_get_sibling(cpunode->child, "comment"); datanode; datanode = xml_get_sibling(datanode->next, "comment")) + const device_config *cpu = cputag_get_cpu(machine, xml_get_attribute_string(cpunode, "tag", "")); + if (cpu != NULL) { - /* Malloc the comment */ - debug_comments[i].comment_info[j] = (debug_comment*) malloc(sizeof(debug_comment)); + debug_cpu_comment_group *comments = cpu_get_debug_data(cpu)->comments; + j = 0; - debug_comments[i].comment_info[j]->address = xml_get_attribute_int(datanode, "address", 0); - debug_comments[i].comment_info[j]->color = xml_get_attribute_int(datanode, "color", 0); - sscanf(xml_get_attribute_string(datanode, "crc", 0), "%08X", &debug_comments[i].comment_info[j]->crc); - strcpy(debug_comments[i].comment_info[j]->text, datanode->value); - debug_comments[i].comment_info[j]->is_valid = 1; + for (datanode = xml_get_sibling(cpunode->child, "comment"); datanode; datanode = xml_get_sibling(datanode->next, "comment")) + { + /* Malloc the comment */ + comments->comment_info[j] = (debug_comment*) malloc(sizeof(debug_comment)); - j++; - } + comments->comment_info[j]->address = xml_get_attribute_int(datanode, "address", 0); + comments->comment_info[j]->color = xml_get_attribute_int(datanode, "color", 0); + sscanf(xml_get_attribute_string(datanode, "crc", 0), "%08X", &comments->comment_info[j]->crc); + strcpy(comments->comment_info[j]->text, datanode->value); + comments->comment_info[j]->is_valid = 1; - debug_comments[i].comment_count = j; + j++; + } - i++; + comments->comment_count = j; + } } /* free the parser */ @@ -564,16 +540,19 @@ static void debug_comment_exit(running_machine *machine) static void debug_comment_free(running_machine *machine) { - int i, j; - - for (i = 0; i < ARRAY_LENGTH(machine->cpu); i++) - if (machine->cpu[i] != NULL) + const device_config *cpu; + + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) + { + debug_cpu_comment_group *comments = cpu_get_debug_data(cpu)->comments; + if (comments != NULL) { - for (j = 0; j < debug_comments[i].comment_count; j++) - { - free(debug_comments[i].comment_info[j]); - } + int j; + + for (j = 0; j < comments->comment_count; j++) + free(comments->comment_info[j]); - debug_comments[i].comment_count = 0; + comments->comment_count = 0; } + } } diff --git a/src/emu/debug/debugcpu.c b/src/emu/debug/debugcpu.c index 76ff505e38c..15a648457e9 100644 --- a/src/emu/debug/debugcpu.c +++ b/src/emu/debug/debugcpu.c @@ -183,7 +183,7 @@ void debug_cpu_init(running_machine *machine) } /* loop over CPUs and build up their info */ - for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { cpu_class_header *classheader = cpu_get_class_header(cpu); cpu_debug_data *info; @@ -249,7 +249,7 @@ void debug_cpu_init(running_machine *machine) } /* first CPU is visible by default */ - global->visiblecpu = machine->cpu[0]; + global->visiblecpu = machine->firstcpu; /* add callback for breaking on VBLANK */ if (machine->primary_screen != NULL) @@ -269,7 +269,7 @@ void debug_cpu_flush_traces(running_machine *machine) { const device_config *cpu; - for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { cpu_debug_data *info = cpu_get_debug_data(cpu); @@ -1014,7 +1014,7 @@ int debug_cpu_breakpoint_clear(running_machine *machine, int bpnum) const device_config *cpu; /* loop over CPUs and find the requested breakpoint */ - for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { cpu_debug_data *info = cpu_get_debug_data(cpu); for (pbp = NULL, bp = info->bplist; bp != NULL; pbp = bp, bp = bp->next) @@ -1055,7 +1055,7 @@ int debug_cpu_breakpoint_enable(running_machine *machine, int bpnum, int enable) const device_config *cpu; /* loop over CPUs and find the requested breakpoint */ - for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { cpu_debug_data *info = cpu_get_debug_data(cpu); for (bp = info->bplist; bp != NULL; bp = bp->next) @@ -1123,7 +1123,7 @@ int debug_cpu_watchpoint_clear(running_machine *machine, int wpnum) int spacenum; /* loop over CPUs and find the requested watchpoint */ - for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { cpu_debug_data *info = cpu_get_debug_data(cpu); @@ -1166,7 +1166,7 @@ int debug_cpu_watchpoint_enable(running_machine *machine, int wpnum, int enable) int spacenum; /* loop over CPUs and address spaces and find the requested watchpoint */ - for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { cpu_debug_data *info = cpu_get_debug_data(cpu); @@ -1934,7 +1934,7 @@ static void debug_cpu_exit(running_machine *machine) int spacenum; /* loop over all watchpoints and breakpoints to free their memory */ - for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { cpu_debug_data *info = cpu_get_debug_data(cpu); @@ -1989,7 +1989,7 @@ static void reset_transient_flags(running_machine *machine) const device_config *cpu; /* loop over CPUs and reset the transient flags */ - for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) cpu_get_debug_data(cpu)->flags &= ~DEBUG_FLAG_TRANSIENT; } @@ -2445,11 +2445,11 @@ static UINT32 dasm_wrapped(const device_config *device, char *buffer, offs_t pc) static const device_config *expression_cpu_index(running_machine *machine, const char *tag) { - int index; + const device_config *cpu; - for (index = 0; index < ARRAY_LENGTH(machine->cpu); index++) - if (machine->cpu[index] != NULL && mame_stricmp(machine->cpu[index]->tag, tag) == 0) - return machine->cpu[index]; + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) + if (mame_stricmp(cpu->tag, tag) == 0) + return cpu; return NULL; } diff --git a/src/emu/debug/debugcpu.h b/src/emu/debug/debugcpu.h index 82d2e6117df..566e008ffae 100644 --- a/src/emu/debug/debugcpu.h +++ b/src/emu/debug/debugcpu.h @@ -71,6 +71,7 @@ typedef int (*debug_instruction_hook_func)(const device_config *device, offs_t c typedef struct _debug_cpu_breakpoint debug_cpu_breakpoint; typedef struct _debug_cpu_watchpoint debug_cpu_watchpoint; +typedef struct _debug_cpu_comment_group debug_cpu_comment_group; typedef struct _debug_trace_info debug_trace_info; @@ -126,6 +127,7 @@ struct _cpu_debug_data cpu_disassemble_func dasm_override; /* pointer to provided override function */ debug_instruction_hook_func instrhook; /* per-instruction callback hook */ debug_cpu_watchpoint * wplist[ADDRESS_SPACES]; /* watchpoint lists for each address space */ + debug_cpu_comment_group *comments; /* disassembly comments */ }; diff --git a/src/emu/debug/debugvw.c b/src/emu/debug/debugvw.c index fa1dcff71e1..207f7213ea7 100644 --- a/src/emu/debug/debugvw.c +++ b/src/emu/debug/debugvw.c @@ -1046,7 +1046,7 @@ static const registers_subview_item *registers_view_enumerate_subviews(running_m int curindex = 0; /* iterate over CPUs with program address spaces */ - for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { registers_subview_item *subview; @@ -1187,7 +1187,7 @@ static void registers_view_recompute(debug_view *view) /* if no CPU, reset to the first one */ if (regdata->device == NULL) - regdata->device = view->machine->cpu[0]; + regdata->device = view->machine->firstcpu; table = cpu_get_state_table(regdata->device); /* reset the view parameters */ @@ -1512,7 +1512,7 @@ static const disasm_subview_item *disasm_view_enumerate_subviews(running_machine int curindex = 0; /* iterate over CPUs with program address spaces */ - for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { const address_space *space = cpu_get_address_space(cpu, ADDRESS_SPACE_PROGRAM); if (space != NULL) @@ -1569,7 +1569,7 @@ static int disasm_view_alloc(debug_view *view) debug_view_expression_alloc(&dasmdata->expression); /* count the number of comments */ - for (cpu = view->machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = view->machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) total_comments += debug_comment_get_count(cpu); /* initialize */ @@ -2433,7 +2433,7 @@ static const memory_subview_item *memory_view_enumerate_subviews(running_machine int itemnum; /* first add all the CPUs' address spaces */ - for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) { const address_space *space = cpu_get_address_space(cpu, spacenum); diff --git a/src/emu/machine/6522via.c b/src/emu/machine/6522via.c index fe72a790d55..52037b0a9b8 100644 --- a/src/emu/machine/6522via.c +++ b/src/emu/machine/6522via.c @@ -262,7 +262,7 @@ static DEVICE_START( via6522 ) /* Default clock is from CPU1 */ if (device->clock == 0) - device_set_clock(device, device->machine->cpu[0]->clock); + device_set_clock(device, device->machine->firstcpu->clock); } diff --git a/src/emu/machine/8042kbdc.c b/src/emu/machine/8042kbdc.c index 617a3837eb2..6e419bca100 100644 --- a/src/emu/machine/8042kbdc.c +++ b/src/emu/machine/8042kbdc.c @@ -584,7 +584,7 @@ WRITE8_HANDLER(kbdc8042_8_w) * the bits low set in the command byte. The only pulse that has * an effect currently is bit 0, which pulses the CPU's reset line */ - cpu_set_input_line(space->machine->cpu[0], INPUT_LINE_RESET, PULSE_LINE); + cpu_set_input_line(space->machine->firstcpu, INPUT_LINE_RESET, PULSE_LINE); at_8042_set_outport(space->machine, kbdc8042.outport | 0x02, 0); break; } diff --git a/src/emu/machine/generic.c b/src/emu/machine/generic.c index 3780b8ce50c..ed337c884cf 100644 --- a/src/emu/machine/generic.c +++ b/src/emu/machine/generic.c @@ -40,7 +40,6 @@ static UINT8 interrupt_enable[8]; - /*************************************************************************** FUNCTION PROTOTYPES ***************************************************************************/ @@ -52,6 +51,23 @@ static void interrupt_reset(running_machine *machine); /*************************************************************************** + INLINE FUNCTIONS +***************************************************************************/ + +/*------------------------------------------------- + interrupt_enabled - return true if interrupts + are enabled for the given CPU +-------------------------------------------------*/ + +INLINE int interrupt_enabled(const device_config *device) +{ + int cpunum = cpu_get_index(device); + return (cpunum >= ARRAY_LENGTH(interrupt_enable) || interrupt_enable[cpunum]); +} + + + +/*************************************************************************** INITIALIZATION ***************************************************************************/ @@ -568,7 +584,7 @@ static void interrupt_reset(running_machine *machine) int cpunum; /* on a reset, enable all interrupts */ - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) + for (cpunum = 0; cpunum < ARRAY_LENGTH(interrupt_enable); cpunum++) interrupt_enable[cpunum] = 1; } @@ -645,7 +661,8 @@ void cpu_interrupt_enable(const device_config *device, int enabled) assert_always(device != NULL, "cpu_interrupt_enable() called for invalid cpu!"); /* set the new state */ - interrupt_enable[cpunum] = enabled; + if (cpunum < ARRAY_LENGTH(interrupt_enable)) + interrupt_enable[cpunum] = enabled; /* make sure there are no queued interrupts */ if (enabled == 0) @@ -671,7 +688,7 @@ WRITE8_HANDLER( interrupt_enable_w ) READ8_HANDLER( interrupt_enable_r ) { - return interrupt_enable[cpu_get_index(space->cpu)]; + return interrupt_enabled(space->cpu); } @@ -681,60 +698,48 @@ READ8_HANDLER( interrupt_enable_r ) ***************************************************************************/ /*------------------------------------------------- - irqn_line_set - set the given IRQ line to the - specified state on the active CPU --------------------------------------------------*/ - -INLINE void irqn_line_set(const device_config *device, int line, int state) -{ - if (interrupt_enable[cpu_get_index(device)]) - cpu_set_input_line(device, line, state); -} - - -/*------------------------------------------------- NMI callbacks -------------------------------------------------*/ -INTERRUPT_GEN( nmi_line_pulse ) { irqn_line_set(device, INPUT_LINE_NMI, PULSE_LINE); } -INTERRUPT_GEN( nmi_line_assert ) { irqn_line_set(device, INPUT_LINE_NMI, ASSERT_LINE); } +INTERRUPT_GEN( nmi_line_pulse ) { if (interrupt_enabled(device)) cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE); } +INTERRUPT_GEN( nmi_line_assert ) { if (interrupt_enabled(device)) cpu_set_input_line(device, INPUT_LINE_NMI, ASSERT_LINE); } /*------------------------------------------------- IRQn callbacks -------------------------------------------------*/ -INTERRUPT_GEN( irq0_line_hold ) { irqn_line_set(device, 0, HOLD_LINE); } -INTERRUPT_GEN( irq0_line_pulse ) { if (interrupt_enable[cpu_get_index(device)]) generic_pulse_irq_line(device, 0); } -INTERRUPT_GEN( irq0_line_assert ) { irqn_line_set(device, 0, ASSERT_LINE); } +INTERRUPT_GEN( irq0_line_hold ) { if (interrupt_enabled(device)) cpu_set_input_line(device, 0, HOLD_LINE); } +INTERRUPT_GEN( irq0_line_pulse ) { if (interrupt_enabled(device)) generic_pulse_irq_line(device, 0); } +INTERRUPT_GEN( irq0_line_assert ) { if (interrupt_enabled(device)) cpu_set_input_line(device, 0, ASSERT_LINE); } -INTERRUPT_GEN( irq1_line_hold ) { irqn_line_set(device, 1, HOLD_LINE); } -INTERRUPT_GEN( irq1_line_pulse ) { if (interrupt_enable[cpu_get_index(device)]) generic_pulse_irq_line(device, 1); } -INTERRUPT_GEN( irq1_line_assert ) { irqn_line_set(device, 1, ASSERT_LINE); } +INTERRUPT_GEN( irq1_line_hold ) { if (interrupt_enabled(device)) cpu_set_input_line(device, 1, HOLD_LINE); } +INTERRUPT_GEN( irq1_line_pulse ) { if (interrupt_enabled(device)) generic_pulse_irq_line(device, 1); } +INTERRUPT_GEN( irq1_line_assert ) { if (interrupt_enabled(device)) cpu_set_input_line(device, 1, ASSERT_LINE); } -INTERRUPT_GEN( irq2_line_hold ) { irqn_line_set(device, 2, HOLD_LINE); } -INTERRUPT_GEN( irq2_line_pulse ) { if (interrupt_enable[cpu_get_index(device)]) generic_pulse_irq_line(device, 2); } -INTERRUPT_GEN( irq2_line_assert ) { irqn_line_set(device, 2, ASSERT_LINE); } +INTERRUPT_GEN( irq2_line_hold ) { if (interrupt_enabled(device)) cpu_set_input_line(device, 2, HOLD_LINE); } +INTERRUPT_GEN( irq2_line_pulse ) { if (interrupt_enabled(device)) generic_pulse_irq_line(device, 2); } +INTERRUPT_GEN( irq2_line_assert ) { if (interrupt_enabled(device)) cpu_set_input_line(device, 2, ASSERT_LINE); } -INTERRUPT_GEN( irq3_line_hold ) { irqn_line_set(device, 3, HOLD_LINE); } -INTERRUPT_GEN( irq3_line_pulse ) { if (interrupt_enable[cpu_get_index(device)]) generic_pulse_irq_line(device, 3); } -INTERRUPT_GEN( irq3_line_assert ) { irqn_line_set(device, 3, ASSERT_LINE); } +INTERRUPT_GEN( irq3_line_hold ) { if (interrupt_enabled(device)) cpu_set_input_line(device, 3, HOLD_LINE); } +INTERRUPT_GEN( irq3_line_pulse ) { if (interrupt_enabled(device)) generic_pulse_irq_line(device, 3); } +INTERRUPT_GEN( irq3_line_assert ) { if (interrupt_enabled(device)) cpu_set_input_line(device, 3, ASSERT_LINE); } -INTERRUPT_GEN( irq4_line_hold ) { irqn_line_set(device, 4, HOLD_LINE); } -INTERRUPT_GEN( irq4_line_pulse ) { if (interrupt_enable[cpu_get_index(device)]) generic_pulse_irq_line(device, 4); } -INTERRUPT_GEN( irq4_line_assert ) { irqn_line_set(device, 4, ASSERT_LINE); } +INTERRUPT_GEN( irq4_line_hold ) { if (interrupt_enabled(device)) cpu_set_input_line(device, 4, HOLD_LINE); } +INTERRUPT_GEN( irq4_line_pulse ) { if (interrupt_enabled(device)) generic_pulse_irq_line(device, 4); } +INTERRUPT_GEN( irq4_line_assert ) { if (interrupt_enabled(device)) cpu_set_input_line(device, 4, ASSERT_LINE); } -INTERRUPT_GEN( irq5_line_hold ) { irqn_line_set(device, 5, HOLD_LINE); } -INTERRUPT_GEN( irq5_line_pulse ) { if (interrupt_enable[cpu_get_index(device)]) generic_pulse_irq_line(device, 5); } -INTERRUPT_GEN( irq5_line_assert ) { irqn_line_set(device, 5, ASSERT_LINE); } +INTERRUPT_GEN( irq5_line_hold ) { if (interrupt_enabled(device)) cpu_set_input_line(device, 5, HOLD_LINE); } +INTERRUPT_GEN( irq5_line_pulse ) { if (interrupt_enabled(device)) generic_pulse_irq_line(device, 5); } +INTERRUPT_GEN( irq5_line_assert ) { if (interrupt_enabled(device)) cpu_set_input_line(device, 5, ASSERT_LINE); } -INTERRUPT_GEN( irq6_line_hold ) { irqn_line_set(device, 6, HOLD_LINE); } -INTERRUPT_GEN( irq6_line_pulse ) { if (interrupt_enable[cpu_get_index(device)]) generic_pulse_irq_line(device, 6); } -INTERRUPT_GEN( irq6_line_assert ) { irqn_line_set(device, 6, ASSERT_LINE); } +INTERRUPT_GEN( irq6_line_hold ) { if (interrupt_enabled(device)) cpu_set_input_line(device, 6, HOLD_LINE); } +INTERRUPT_GEN( irq6_line_pulse ) { if (interrupt_enabled(device)) generic_pulse_irq_line(device, 6); } +INTERRUPT_GEN( irq6_line_assert ) { if (interrupt_enabled(device)) cpu_set_input_line(device, 6, ASSERT_LINE); } -INTERRUPT_GEN( irq7_line_hold ) { irqn_line_set(device, 7, HOLD_LINE); } -INTERRUPT_GEN( irq7_line_pulse ) { if (interrupt_enable[cpu_get_index(device)]) generic_pulse_irq_line(device, 7); } -INTERRUPT_GEN( irq7_line_assert ) { irqn_line_set(device, 7, ASSERT_LINE); } +INTERRUPT_GEN( irq7_line_hold ) { if (interrupt_enabled(device)) cpu_set_input_line(device, 7, HOLD_LINE); } +INTERRUPT_GEN( irq7_line_pulse ) { if (interrupt_enabled(device)) generic_pulse_irq_line(device, 7); } +INTERRUPT_GEN( irq7_line_assert ) { if (interrupt_enabled(device)) cpu_set_input_line(device, 7, ASSERT_LINE); } diff --git a/src/emu/machine/latch8.c b/src/emu/machine/latch8.c index 5244e9caa6d..c59a22c513b 100644 --- a/src/emu/machine/latch8.c +++ b/src/emu/machine/latch8.c @@ -84,7 +84,7 @@ READ8_DEVICE_HANDLER( latch8_r ) if (latch8->has_read) { /* temporary hack until all relevant systems are devices */ - const address_space *space = cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM); + const address_space *space = cpu_get_address_space(device->machine->firstcpu, ADDRESS_SPACE_PROGRAM); int i; for (i=0; i<8; i++) { diff --git a/src/emu/machine/tmp68301.c b/src/emu/machine/tmp68301.c index 19ec2369a7f..5cbb8844ef7 100644 --- a/src/emu/machine/tmp68301.c +++ b/src/emu/machine/tmp68301.c @@ -47,7 +47,7 @@ static TIMER_CALLBACK( tmp68301_timer_callback ) tmp68301_irq_vector[level] = IVNR & 0x00e0; tmp68301_irq_vector[level] += 4+i; - cpu_set_input_line(machine->cpu[0],level,HOLD_LINE); + cpu_set_input_line(machine->firstcpu,level,HOLD_LINE); } if (TCR & 0x0080) // N/1 @@ -90,7 +90,7 @@ static void tmp68301_update_timer( running_machine *machine, int i ) { int scale = (TCR & 0x3c00)>>10; // P4..1 if (scale > 8) scale = 8; - duration = attotime_mul(ATTOTIME_IN_HZ(cpu_get_clock(machine->cpu[0])), (1 << scale) * max); + duration = attotime_mul(ATTOTIME_IN_HZ(cpu_get_clock(machine->firstcpu)), (1 << scale) * max); } break; } @@ -115,7 +115,7 @@ MACHINE_RESET( tmp68301 ) for (i = 0; i < 3; i++) tmp68301_IE[i] = 0; - cpu_set_irq_callback(machine->cpu[0], tmp68301_irq_callback); + cpu_set_irq_callback(machine->firstcpu, tmp68301_irq_callback); } /* Update the IRQ state based on all possible causes */ @@ -145,7 +145,7 @@ static void update_irq_state(running_machine *machine) tmp68301_IE[i] = 0; // Interrupts are edge triggerred - cpu_set_input_line(machine->cpu[0],level,HOLD_LINE); + cpu_set_input_line(machine->firstcpu,level,HOLD_LINE); } } } diff --git a/src/emu/mame.c b/src/emu/mame.c index 6704b064916..d9843ddb887 100644 --- a/src/emu/mame.c +++ b/src/emu/mame.c @@ -240,7 +240,7 @@ INLINE void eat_all_cpu_cycles(running_machine *machine) { const device_config *cpu; - for (cpu = machine->cpu[0]; cpu != NULL; cpu = cpu->typenext) + for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) cpu_eat_cycles(cpu, 1000000000); } @@ -1399,7 +1399,6 @@ static int parse_ini_file(core_options *options, const char *name) static running_machine *create_machine(const game_driver *driver) { running_machine *machine; - int cpunum; /* allocate memory for the machine */ machine = (running_machine *)malloc(sizeof(*machine)); @@ -1428,9 +1427,7 @@ static running_machine *create_machine(const game_driver *driver) } /* 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->firstcpu = cpu_first(machine->config); machine->primary_screen = video_screen_first(machine->config); /* attach this machine to all the devices in the configuration */ diff --git a/src/emu/mame.h b/src/emu/mame.h index b847643f8cb..c0f61bbbedd 100644 --- a/src/emu/mame.h +++ b/src/emu/mame.h @@ -152,7 +152,7 @@ struct _running_machine const input_port_config *portconfig; /* points to a list of input port configurations */ /* CPU information */ - const device_config * cpu[8]; /* array of first 8 CPU devices */ + const device_config * firstcpu; /* first CPU (allows for quick iteration via typenext) */ /* game-related information */ const game_driver * gamedrv; /* points to the definition of the game machine */ diff --git a/src/emu/sound/scsp.c b/src/emu/sound/scsp.c index 67c07770925..4c25af13ad8 100644 --- a/src/emu/sound/scsp.c +++ b/src/emu/sound/scsp.c @@ -705,7 +705,7 @@ static void SCSP_UpdateSlotReg(struct _SCSP *SCSP,int s,int r) static void SCSP_UpdateReg(struct _SCSP *SCSP, int reg) { /* temporary hack until this is converted to a device */ - const address_space *space = memory_find_address_space(SCSP->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM); + const address_space *space = memory_find_address_space(SCSP->device->machine->firstcpu, ADDRESS_SPACE_PROGRAM); switch(reg&0x3f) { case 0x2: @@ -1208,7 +1208,7 @@ static void dma_scsp(const address_space *space, struct _SCSP *SCSP) /*Job done,request a dma end irq*/ if(scsp_regs[0x1e/2] & 0x10) - cpu_set_input_line(space->machine->cpu[2],dma_transfer_end,HOLD_LINE); + cpu_set_input_line(device_list_find_by_index(space->machine->config->devicelist, CPU, 2),dma_transfer_end,HOLD_LINE); } #ifdef UNUSED_FUNCTION @@ -1312,7 +1312,7 @@ WRITE16_DEVICE_HANDLER( scsp_w ) SCSP->scsp_dtlg = scsp_regs[0x416/2] & 0x0ffe; if(scsp_dexe) { - dma_scsp(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM), SCSP); + dma_scsp(cpu_get_address_space(device->machine->firstcpu, ADDRESS_SPACE_PROGRAM), SCSP); scsp_regs[0x416/2]^=0x1000;//disable starting bit } break; @@ -1320,7 +1320,7 @@ WRITE16_DEVICE_HANDLER( scsp_w ) case 0x42a: if(stv_scu && !(stv_scu[40] & 0x40) /*&& scsp_regs[0x42c/2] & 0x20*/)/*Main CPU allow sound irq*/ { - cpu_set_input_line_and_vector(device->machine->cpu[0], 9, HOLD_LINE , 0x46); + cpu_set_input_line_and_vector(device->machine->firstcpu, 9, HOLD_LINE , 0x46); logerror("SCSP: Main CPU interrupt\n"); } break; diff --git a/src/emu/ui.c b/src/emu/ui.c index dd3231542fd..4682c26ac07 100644 --- a/src/emu/ui.c +++ b/src/emu/ui.c @@ -978,7 +978,7 @@ astring *game_info_astring(running_machine *machine, astring *string) astring_printf(string, "%s\n%s %s\n\nCPU:\n", machine->gamedrv->description, machine->gamedrv->year, machine->gamedrv->manufacturer); /* loop over all CPUs */ - for (device = machine->cpu[0]; device != NULL; device = scandevice) + for (device = machine->firstcpu; device != NULL; device = scandevice) { /* count how many identical CPUs we have */ count = 1; @@ -1454,13 +1454,13 @@ static slider_state *slider_init(running_machine *machine) /* add CPU overclocking (cheat only) */ if (options_get_bool(mame_options(), OPTION_CHEAT)) { - for (item = 0; item < ARRAY_LENGTH(machine->cpu); item++) - if (machine->cpu[item] != NULL) - { - astring_printf(string, "Overclock CPU %s", machine->cpu[item]->tag); - *tailptr = slider_alloc(machine, astring_c(string), 10, 1000, 2000, 1, slider_overclock, (void *)(FPTR)item); - tailptr = &(*tailptr)->next; - } + for (device = machine->firstcpu; device != NULL; device = cpu_next(device)) + { + void *param = (void *)device; + astring_printf(string, "Overclock CPU %s", device->tag); + *tailptr = slider_alloc(machine, astring_c(string), 10, 1000, 2000, 1, slider_overclock, param); + tailptr = &(*tailptr)->next; + } } /* add screen parameters */ @@ -1628,12 +1628,12 @@ static INT32 slider_adjuster(running_machine *machine, void *arg, astring *strin static INT32 slider_overclock(running_machine *machine, void *arg, astring *string, INT32 newval) { - int which = (FPTR)arg; + const device_config *cpu = (const device_config *)arg; if (newval != SLIDER_NOCHANGE) - cpu_set_clockscale(machine->cpu[which], (float)newval * 0.001f); + cpu_set_clockscale(cpu, (float)newval * 0.001f); if (string != NULL) - astring_printf(string, "%3.0f%%", floor(cpu_get_clockscale(machine->cpu[which]) * 100.0f + 0.5f)); - return floor(cpu_get_clockscale(machine->cpu[which]) * 1000.0f + 0.5f); + astring_printf(string, "%3.0f%%", floor(cpu_get_clockscale(cpu) * 100.0f + 0.5f)); + return floor(cpu_get_clockscale(cpu) * 1000.0f + 0.5f); } diff --git a/src/mame/machine/atarigen.c b/src/mame/machine/atarigen.c index ed70ee7de68..90ef9d4ca4a 100644 --- a/src/mame/machine/atarigen.c +++ b/src/mame/machine/atarigen.c @@ -325,7 +325,7 @@ static TIMER_CALLBACK( scanline_interrupt_callback ) emu_timer *timer = get_scanline_interrupt_timer_for_screen(screen); /* generate the interrupt */ - atarigen_scanline_int_gen(machine->cpu[0]); + atarigen_scanline_int_gen(cputag_get_cpu(machine, "maincpu")); /* set a new timer to go off at the same scan line next frame */ timer_adjust_oneshot(timer, video_screen_get_frame_period(screen), 0); @@ -858,7 +858,7 @@ static TIMER_CALLBACK( delayed_6502_sound_w ) /* set up the states and signal the sound interrupt to the main CPU */ atarigen_sound_to_cpu = param; atarigen_sound_to_cpu_ready = 1; - atarigen_sound_int_gen(machine->cpu[0]); + atarigen_sound_int_gen(cputag_get_cpu(machine, "maincpu")); } @@ -1238,7 +1238,7 @@ static void atarivc_common_w(const device_config *screen, offs_t offset, UINT16 /* scanline IRQ ack here */ case 0x1e: /* hack: this should be a device */ - atarigen_scanline_int_ack_w(cpu_get_address_space(screen->machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0, 0, 0xffff); + atarigen_scanline_int_ack_w(cputag_get_address_space(screen->machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0, 0, 0xffff); break; /* log anything else */ @@ -1468,6 +1468,8 @@ int atarigen_get_hblank(const device_config *screen) void atarigen_halt_until_hblank_0(const device_config *screen) { + const device_config *cpu = cputag_get_cpu(screen->machine, "maincpu"); + /* halt the CPU until the next HBLANK */ int hpos = video_screen_get_hpos(screen); int width = video_screen_get_width(screen); @@ -1480,8 +1482,8 @@ void atarigen_halt_until_hblank_0(const device_config *screen) /* halt and set a timer to wake up */ fraction = (double)(hblank - hpos) / (double)width; - timer_set(screen->machine, double_to_attotime(attotime_to_double(video_screen_get_scan_period(screen)) * fraction), NULL, 0, unhalt_cpu); - cpu_set_input_line(screen->machine->cpu[0], INPUT_LINE_HALT, ASSERT_LINE); + timer_set(screen->machine, double_to_attotime(attotime_to_double(video_screen_get_scan_period(screen)) * fraction), (void *)cpu, 0, unhalt_cpu); + cpu_set_input_line(cpu, INPUT_LINE_HALT, ASSERT_LINE); } @@ -1569,7 +1571,8 @@ WRITE32_HANDLER( atarigen_666_paletteram32_w ) static TIMER_CALLBACK( unhalt_cpu ) { - cpu_set_input_line(machine->cpu[param], INPUT_LINE_HALT, CLEAR_LINE); + const device_config *cpu = (const device_config *)ptr; + cpu_set_input_line(cpu, INPUT_LINE_HALT, CLEAR_LINE); } diff --git a/src/mame/video/avgdvg.c b/src/mame/video/avgdvg.c index d267af7c102..77ce2825b94 100644 --- a/src/mame/video/avgdvg.c +++ b/src/mame/video/avgdvg.c @@ -1276,7 +1276,7 @@ WRITE16_HANDLER( avgdvg_reset_word_w ) MACHINE_RESET( avgdvg ) { - avgdvg_reset_w (cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM),0,0); + avgdvg_reset_w (cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM),0,0); } diff --git a/src/mame/video/system1.c b/src/mame/video/system1.c index 77fd9b2cdcd..c6ef423051c 100644 --- a/src/mame/video/system1.c +++ b/src/mame/video/system1.c @@ -497,8 +497,8 @@ static void video_update_common(const device_config *screen, bitmap_t *bitmap, c /* iterate over rows */ for (y = cliprect->min_y; y <= cliprect->max_y; y++) { - UINT16 *fgbase = BITMAP_ADDR16(fgpixmap, y, 0); - UINT16 *sprbase = BITMAP_ADDR16(sprite_bitmap, y, 0); + UINT16 *fgbase = BITMAP_ADDR16(fgpixmap, y & 0xff, 0); + UINT16 *sprbase = BITMAP_ADDR16(sprite_bitmap, y & 0xff, 0); UINT16 *dstbase = BITMAP_ADDR16(bitmap, y, 0); int bgy = (y + bgyscroll) & 0x1ff; int bgxscroll = bgrowscroll[y / 8]; |