summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/mame.c
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2008-12-11 09:40:22 +0000
committer Aaron Giles <aaron@aarongiles.com>2008-12-11 09:40:22 +0000
commitd87ef8f79b70ca8117b8f365d4836ad4448086f7 (patch)
treeae903a5c8f3aa26aca66e9425542e8b3d44c716a /src/emu/mame.c
parentc8944548df7b46b621039b1cea123b53c499664e (diff)
Here's the big one....
Added new function cpuexec_describe_context(machine) which can be used in logerror() and other printf-style functions to return a description of the current CPU/PC given only the machine. Changed several dozen sites to use this instead of directly interrogating the activecpu. Removed all other uses of activecpu throughout the system. Removed activecpu from the machine structure to prevent future abuse. Removed cpu_push_context() and cpu_pop_context(), and all call sites. Voodoo devices now require a CPU to be defined in the configuration in order to know whom to steal cycles from or stall when FIFOs get full. Updated all voodoo users to specify one. CPD1869 devices now also require a CPU to be defined in the configuration, in order to know which CPU's registers to fetch. Updated all cdp1869 users to specify one. Many other small changes to make this all work.
Diffstat (limited to 'src/emu/mame.c')
-rw-r--r--src/emu/mame.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/src/emu/mame.c b/src/emu/mame.c
index 98e5b7766d6..a5f654f18dd 100644
--- a/src/emu/mame.c
+++ b/src/emu/mame.c
@@ -235,6 +235,26 @@ static void logfile_callback(running_machine *machine, const char *buffer);
***************************************************************************/
/*-------------------------------------------------
+ eat_all_cpu_cycles - eat a ton of cycles on
+ all CPUs to force a quick exit
+-------------------------------------------------*/
+
+INLINE void eat_all_cpu_cycles(running_machine *machine)
+{
+ int cpunum;
+
+ for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++)
+ if (machine->cpu[cpunum] != NULL)
+ cpu_eat_cycles(machine->cpu[cpunum], 1000000000);
+}
+
+
+
+/***************************************************************************
+ CORE IMPLEMENTATION
+***************************************************************************/
+
+/*-------------------------------------------------
mame_execute - run the core emulation
-------------------------------------------------*/
@@ -559,8 +579,7 @@ void mame_schedule_exit(running_machine *machine)
mame->exit_pending = TRUE;
/* if we're executing, abort out immediately */
- if (machine->activecpu != NULL)
- cpu_eat_cycles(machine->activecpu, 1000000000);
+ eat_all_cpu_cycles(machine);
/* if we're autosaving on exit, schedule a save as well */
if (options_get_bool(mame_options(), OPTION_AUTOSAVE) && (machine->gamedrv->flags & GAME_SUPPORTS_SAVE))
@@ -579,8 +598,7 @@ void mame_schedule_hard_reset(running_machine *machine)
mame->hard_reset_pending = TRUE;
/* if we're executing, abort out immediately */
- if (machine->activecpu != NULL)
- cpu_eat_cycles(machine->activecpu, 1000000000);
+ eat_all_cpu_cycles(machine);
}
@@ -599,8 +617,7 @@ void mame_schedule_soft_reset(running_machine *machine)
mame_pause(machine, FALSE);
/* if we're executing, abort out immediately */
- if (machine->activecpu != NULL)
- cpu_eat_cycles(machine->activecpu, 1000000000);
+ eat_all_cpu_cycles(machine);
}
@@ -616,8 +633,7 @@ void mame_schedule_new_driver(running_machine *machine, const game_driver *drive
mame->new_driver_pending = driver;
/* if we're executing, abort out immediately */
- if (machine->activecpu != NULL)
- cpu_eat_cycles(machine->activecpu, 1000000000);
+ eat_all_cpu_cycles(machine);
}
@@ -1732,14 +1748,10 @@ static void handle_save(running_machine *machine)
for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++)
if (machine->cpu[cpunum] != NULL)
{
- cpu_push_context(machine->cpu[cpunum]);
-
/* save the CPU data */
state_save_push_tag(cpunum + 1);
state_save_save_continue(machine);
state_save_pop_tag();
-
- cpu_pop_context();
}
/* finish and close */
@@ -1812,14 +1824,10 @@ static void handle_load(running_machine *machine)
for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++)
if (machine->cpu[cpunum] != NULL)
{
- cpu_push_context(machine->cpu[cpunum]);
-
/* load the CPU data */
state_save_push_tag(cpunum + 1);
state_save_load_continue(machine);
state_save_pop_tag();
-
- cpu_pop_context();
}
/* finish and close */