summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2008-05-15 08:22:17 +0000
committer Aaron Giles <aaron@aarongiles.com>2008-05-15 08:22:17 +0000
commit44fbeff9bf9f303394b927dac4af213218bcc2ff (patch)
tree4bec70e4f8c2ef781e066294d1fd5a3320028a56
parent1caf8deb7e9fe936e7661aa428e9666ecce3c0bb (diff)
From: Atari Ace [mailto:atari_ace@verizon.net]
Subject: [patch] Remove opbase globals from the public interface Hi mamedev, There are several variables associated with opbase handling which are global and documented in memory.h and thus their use is not well controlled. This patch attempts to remedy this. Because they are used in various inline memory functions, they can't yet be made local to memory.c, but by rescoping their declaration they can be hidden, much like we hide totalcpu. Most of the uses are in OPBASE_HANDLER() macros, so by encapsulating the opbase state into a struct and adding that to the handler interface those can be converted to local variable manipulation. There is one use in missile.c in a MACHINE_START that I simply removed, it shouldn't be needed. One side effect of this patch is that the various unsafe memory macros can't be used directly, they will be a compiler error now. That is probably for the best. ~aa
-rw-r--r--src/emu/cpu/z180/z180dasm.c4
-rw-r--r--src/emu/cpu/z80/z80dasm.c4
-rw-r--r--src/emu/debug/debugvw.c12
-rw-r--r--src/emu/memory.c99
-rw-r--r--src/emu/memory.h61
-rw-r--r--src/mame/drivers/atarig42.c2
-rw-r--r--src/mame/drivers/atarisy2.c2
-rw-r--r--src/mame/drivers/cps3.c29
-rw-r--r--src/mame/drivers/hng64.c2
-rw-r--r--src/mame/drivers/leland.c10
-rw-r--r--src/mame/drivers/missile.c5
-rw-r--r--src/mame/machine/snes.c4
12 files changed, 101 insertions, 133 deletions
diff --git a/src/emu/cpu/z180/z180dasm.c b/src/emu/cpu/z180/z180dasm.c
index 7a315d3823b..ff718e51092 100644
--- a/src/emu/cpu/z180/z180dasm.c
+++ b/src/emu/cpu/z180/z180dasm.c
@@ -459,7 +459,7 @@ offs_t z180_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram
if( op1 == 0xcb )
{
offset = (INT8) opram[pos++];
- op1 = opram[pos++]; /* fourth byte from opcode_arg_base! */
+ op1 = opram[pos++]; /* fourth byte from opbase.ram! */
d = &mnemonic_xx_cb[op1];
}
else d = &mnemonic_xx[op1];
@@ -470,7 +470,7 @@ offs_t z180_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram
if( op1 == 0xcb )
{
offset = (INT8) opram[pos++];
- op1 = opram[pos++]; /* fourth byte from opcode_arg_base! */
+ op1 = opram[pos++]; /* fourth byte from opbase.ram! */
d = &mnemonic_xx_cb[op1];
}
else d = &mnemonic_xx[op1];
diff --git a/src/emu/cpu/z80/z80dasm.c b/src/emu/cpu/z80/z80dasm.c
index 2d33a39af98..356db73c6d2 100644
--- a/src/emu/cpu/z80/z80dasm.c
+++ b/src/emu/cpu/z80/z80dasm.c
@@ -455,7 +455,7 @@ unsigned z80_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opra
if( op1 == 0xcb )
{
offset = (INT8) opram[pos++];
- op1 = opram[pos++]; /* fourth byte from opcode_arg_base! */
+ op1 = opram[pos++]; /* fourth byte from opbase.ram! */
d = &mnemonic_xx_cb[op1];
}
else d = &mnemonic_xx[op1];
@@ -466,7 +466,7 @@ unsigned z80_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opra
if( op1 == 0xcb )
{
offset = (INT8) opram[pos++];
- op1 = opram[pos++]; /* fourth byte from opcode_arg_base! */
+ op1 = opram[pos++]; /* fourth byte from opbase.ram! */
d = &mnemonic_xx_cb[op1];
}
else d = &mnemonic_xx[op1];
diff --git a/src/emu/debug/debugvw.c b/src/emu/debug/debugvw.c
index c05a28af9e1..ac40410a96a 100644
--- a/src/emu/debug/debugvw.c
+++ b/src/emu/debug/debugvw.c
@@ -113,8 +113,8 @@ struct _debug_view_disasm
UINT8 right_column; /* right column? */
UINT32 backwards_steps; /* number of backwards steps */
UINT32 dasm_width; /* width of the disassembly area */
- UINT8 * last_opcode_base; /* last opcode base */
- UINT8 * last_opcode_arg_base; /* last opcode arg base */
+ UINT8 * last_opbase_rom; /* last opbase.rom */
+ UINT8 * last_opbase_ram; /* last opbase.ram */
UINT32 last_change_count; /* last comment change count */
offs_t last_pcbyte; /* last PC byte value */
UINT32 active_address; /* the address cursor_row is pointing to */
@@ -1461,6 +1461,7 @@ static void disasm_generate_bytes(offs_t pcbyte, int numbytes, const debug_cpu_i
static int disasm_recompute(debug_view *view, offs_t pc, int startline, int lines, int original_cpunum)
{
+ extern opbase_data opbase;
debug_view_disasm *dasmdata = view->extra_data;
const debug_cpu_info *cpuinfo = debug_get_cpu_info(dasmdata->cpunum);
int chunksize, minbytes, maxbytes, maxbytes_clamped;
@@ -1596,8 +1597,8 @@ static int disasm_recompute(debug_view *view, offs_t pc, int startline, int line
memory_set_opbase(activecpu_get_physical_pc_byte());
/* update opcode base information */
- dasmdata->last_opcode_base = opcode_base;
- dasmdata->last_opcode_arg_base = opcode_arg_base;
+ dasmdata->last_opbase_rom = opbase.rom;
+ dasmdata->last_opbase_ram = opbase.ram;
dasmdata->last_change_count = debug_comment_all_change_count();
/* now longer need to recompute */
@@ -1613,6 +1614,7 @@ static int disasm_recompute(debug_view *view, offs_t pc, int startline, int line
static void disasm_update(debug_view *view)
{
+ extern opbase_data opbase;
debug_view_disasm *dasmdata = view->extra_data;
const debug_cpu_info *cpuinfo = debug_get_cpu_info(dasmdata->cpunum);
offs_t pc = cpunum_get_reg(dasmdata->cpunum, REG_PC);
@@ -1676,7 +1678,7 @@ static void disasm_update(debug_view *view)
}
/* if the opcode base has changed, rework things */
- if (opcode_base != dasmdata->last_opcode_base || opcode_arg_base != dasmdata->last_opcode_arg_base)
+ if (opbase.rom != dasmdata->last_opbase_rom || opbase.ram != dasmdata->last_opbase_ram)
dasmdata->recompute = TRUE;
/* if the comments have changed, redo it */
diff --git a/src/emu/memory.c b/src/emu/memory.c
index 96eb735eeef..c3d87bd1b25 100644
--- a/src/emu/memory.c
+++ b/src/emu/memory.c
@@ -218,7 +218,7 @@ struct _memory_block
UINT8 spacenum; /* which address space are we associated with? */
UINT8 isallocated; /* did we allocate this ourselves? */
offs_t bytestart, byteend; /* byte-normalized start/end for verifying a match */
- UINT8 * data; /* pointer to the data for this block */
+ UINT8 * data; /* pointer to the data for this block */
};
typedef struct _bank_data bank_info;
@@ -293,14 +293,8 @@ struct _cpu_data
UINT8 * region; /* pointer to memory region */
size_t regionsize; /* size of region, in bytes */
- opbase_handler_func opbase; /* opcode base handler */
-
- void * op_ram; /* dynamic RAM base pointer */
- void * op_rom; /* dynamic ROM base pointer */
- offs_t op_mask; /* dynamic ROM address mask */
- offs_t op_mem_min; /* dynamic ROM/RAM min */
- offs_t op_mem_max; /* dynamic ROM/RAM max */
- UINT8 opcode_entry; /* opcode base handler */
+ opbase_handler_func opbase_handler; /* opcode base handler */
+ opbase_data opbase; /* dynamic opcode data */
UINT8 spacemask; /* mask of which address spaces are used */
addrspace_data space[ADDRESS_SPACES]; /* info about each address space */
@@ -312,12 +306,7 @@ struct _cpu_data
GLOBAL VARIABLES
***************************************************************************/
-UINT8 * opcode_base; /* opcode base */
-UINT8 * opcode_arg_base; /* opcode argument base */
-offs_t opcode_mask; /* mask to apply to the opcode address */
-offs_t opcode_memory_min; /* opcode memory minimum */
-offs_t opcode_memory_max; /* opcode memory maximum */
-UINT8 opcode_entry; /* opcode readmem entry */
+opbase_data opbase; /* opcode data */
address_space active_address_space[ADDRESS_SPACES];/* address space data */
@@ -329,7 +318,7 @@ static memory_block * memory_block_list; /* head of the list of memory block
static int cur_context; /* current CPU context */
-static opbase_handler_func opbasefunc; /* opcode base override */
+static opbase_handler_func opbase_handler; /* opcode base override */
static UINT8 debugger_access; /* treat accesses as coming from the debugger */
static UINT8 log_unmap[ADDRESS_SPACES]; /* log unmapped memory accesses */
@@ -439,7 +428,7 @@ static void mem_dump(void);
INLINE void force_opbase_update(void)
{
- opcode_entry = 0xff;
+ opbase.entry = 0xff;
memory_set_opbase(activecpu_get_physical_pc_byte());
}
@@ -552,21 +541,11 @@ void memory_set_context(int activecpu)
/* remember dynamic RAM/ROM */
if (cur_context != -1)
{
- cpudata[cur_context].op_ram = opcode_arg_base;
- cpudata[cur_context].op_rom = opcode_base;
- cpudata[cur_context].op_mask = opcode_mask;
- cpudata[cur_context].op_mem_min = opcode_memory_min;
- cpudata[cur_context].op_mem_max = opcode_memory_max;
- cpudata[cur_context].opcode_entry = opcode_entry;
+ cpudata[cur_context].opbase = opbase;
}
cur_context = activecpu;
- opcode_arg_base = cpudata[activecpu].op_ram;
- opcode_base = cpudata[activecpu].op_rom;
- opcode_mask = cpudata[activecpu].op_mask;
- opcode_memory_min = cpudata[activecpu].op_mem_min;
- opcode_memory_max = cpudata[activecpu].op_mem_max;
- opcode_entry = cpudata[activecpu].opcode_entry;
+ opbase = cpudata[activecpu].opbase;
/* program address space */
active_address_space[ADDRESS_SPACE_PROGRAM].bytemask = cpudata[activecpu].space[ADDRESS_SPACE_PROGRAM].bytemask;
@@ -598,7 +577,7 @@ void memory_set_context(int activecpu)
active_address_space[ADDRESS_SPACE_IO].accessors = cpudata[activecpu].space[ADDRESS_SPACE_IO].accessors;
}
- opbasefunc = cpudata[activecpu].opbase;
+ opbase_handler = cpudata[activecpu].opbase_handler;
#ifdef ENABLE_DEBUGGER
if (activecpu != -1 && Machine->debug_mode)
@@ -890,7 +869,7 @@ void memory_set_decrypted_region(int cpunum, offs_t addrstart, offs_t addrend, v
found = TRUE;
/* if we are executing from here, force an opcode base update */
- if (cpu_getactivecpu() >= 0 && cpunum == cur_context && opcode_entry == banknum)
+ if (cpu_getactivecpu() >= 0 && cpunum == cur_context && opbase.entry == banknum)
force_opbase_update();
}
@@ -914,10 +893,10 @@ void memory_set_decrypted_region(int cpunum, offs_t addrstart, offs_t addrend, v
opbase_handler_func memory_set_opbase_handler(int cpunum, opbase_handler_func function)
{
- opbase_handler_func old = cpudata[cpunum].opbase;
- cpudata[cpunum].opbase = function;
+ opbase_handler_func old = cpudata[cpunum].opbase_handler;
+ cpudata[cpunum].opbase_handler = function;
if (cpunum == cpu_getactivecpu())
- opbasefunc = function;
+ opbase_handler = function;
return old;
}
@@ -935,9 +914,9 @@ void memory_set_opbase(offs_t byteaddress)
UINT8 entry;
/* allow overrides */
- if (opbasefunc != NULL)
+ if (opbase_handler != NULL)
{
- byteaddress = (*opbasefunc)(Machine, byteaddress);
+ byteaddress = (*opbase_handler)(Machine, byteaddress, &opbase);
if (byteaddress == ~0)
return;
}
@@ -949,7 +928,7 @@ void memory_set_opbase(offs_t byteaddress)
entry = space->readlookup[LEVEL2_INDEX(entry,byteaddress)];
/* keep track of current entry */
- opcode_entry = entry;
+ opbase.entry = entry;
/* if we don't map to a bank, see if there are any banks we can map to */
if (entry < STATIC_BANK1 || entry >= STATIC_RAM)
@@ -980,11 +959,11 @@ void memory_set_opbase(offs_t byteaddress)
/* compute the adjusted base */
handlers = &active_address_space[ADDRESS_SPACE_PROGRAM].readhandlers[entry];
- opcode_mask = handlers->bytemask;
- opcode_arg_base = base - (handlers->bytestart & opcode_mask);
- opcode_base = based - (handlers->bytestart & opcode_mask);
- opcode_memory_min = handlers->bytestart;
- opcode_memory_max = handlers->byteend;
+ opbase.mask = handlers->bytemask;
+ opbase.ram = base - (handlers->bytestart & opbase.mask);
+ opbase.rom = based - (handlers->bytestart & opbase.mask);
+ opbase.mem_min = handlers->bytestart;
+ opbase.mem_max = handlers->byteend;
}
@@ -1059,34 +1038,24 @@ void *memory_get_op_ptr(int cpunum, offs_t byteaddress, int arg)
UINT8 entry;
/* if there is a custom mapper, use that */
- if (cpudata[cpunum].opbase != NULL)
+ if (cpudata[cpunum].opbase_handler != NULL)
{
/* need to save opcode info */
- UINT8 *saved_opcode_base = opcode_base;
- UINT8 *saved_opcode_arg_base = opcode_arg_base;
- offs_t saved_opcode_mask = opcode_mask;
- offs_t saved_opcode_memory_min = opcode_memory_min;
- offs_t saved_opcode_memory_max = opcode_memory_max;
- UINT8 saved_opcode_entry = opcode_entry;
+ opbase_data saved_opbase = opbase;
/* query the handler */
- offs_t new_byteaddress = (*cpudata[cpunum].opbase)(Machine, byteaddress);
+ offs_t new_byteaddress = (*cpudata[cpunum].opbase_handler)(Machine, byteaddress, &opbase);
/* if it returns ~0, we use whatever data the handler set */
if (new_byteaddress == ~0)
- ptr = arg ? &opcode_arg_base[byteaddress] : &opcode_base[byteaddress];
+ ptr = arg ? &opbase.ram[byteaddress] : &opbase.rom[byteaddress];
/* otherwise, we use the new offset in the generic case below */
else
byteaddress = new_byteaddress;
/* restore opcode info */
- opcode_base = saved_opcode_base;
- opcode_arg_base = saved_opcode_arg_base;
- opcode_mask = saved_opcode_mask;
- opcode_memory_min = saved_opcode_memory_min;
- opcode_memory_max = saved_opcode_memory_max;
- opcode_entry = saved_opcode_entry;
+ opbase = saved_opbase;
/* if we got our pointer, we're done */
if (ptr != NULL)
@@ -1183,7 +1152,7 @@ void memory_set_bank(int banknum, int entrynum)
bankd_ptr[banknum] = bankdata[banknum].entryd[entrynum];
/* if we're executing out of this bank, adjust the opbase pointer */
- if (opcode_entry == banknum && cpu_getactivecpu() >= 0)
+ if (opbase.entry == banknum && cpu_getactivecpu() >= 0)
force_opbase_update();
}
@@ -1226,7 +1195,7 @@ void memory_set_bankptr(int banknum, void *base)
bank_ptr[banknum] = base;
/* if we're executing out of this bank, adjust the opbase pointer */
- if (opcode_entry == banknum && cpu_getactivecpu() >= 0)
+ if (opbase.entry == banknum && cpu_getactivecpu() >= 0)
force_opbase_update();
}
@@ -1459,12 +1428,12 @@ static void memory_init_cpudata(const machine_config *config)
}
/* set the RAM/ROM base */
- cpu->op_ram = cpu->op_rom = memory_region(REGION_CPU1 + cpunum);
- cpu->op_mask = cpu->space[ADDRESS_SPACE_PROGRAM].bytemask;
- cpu->op_mem_min = 0;
- cpu->op_mem_max = memory_region_length(REGION_CPU1 + cpunum);
- cpu->opcode_entry = STATIC_UNMAP;
- cpu->opbase = NULL;
+ cpu->opbase.ram = cpu->opbase.rom = memory_region(REGION_CPU1 + cpunum);
+ cpu->opbase.mask = cpu->space[ADDRESS_SPACE_PROGRAM].bytemask;
+ cpu->opbase.mem_min = 0;
+ cpu->opbase.mem_max = memory_region_length(REGION_CPU1 + cpunum);
+ cpu->opbase.entry = STATIC_UNMAP;
+ cpu->opbase_handler = NULL;
}
}
diff --git a/src/emu/memory.h b/src/emu/memory.h
index 54598177d97..f4194b2769c 100644
--- a/src/emu/memory.h
+++ b/src/emu/memory.h
@@ -91,8 +91,21 @@ typedef struct _handler_data handler_data;
typedef UINT32 offs_t;
+/* opbase_data contains state data for opcode handling */
+typedef struct _opbase_data opbase_data;
+struct _opbase_data
+{
+ UINT8 * rom; /* opcode ROM base pointer */
+ UINT8 * ram; /* opcode RAM base pointer */
+ offs_t mask; /* opcode ROM address mask */
+ offs_t mem_min; /* opcode ROM/RAM min */
+ offs_t mem_max; /* opcode ROM/RAM max */
+ UINT8 entry; /* opcode readmem entry */
+};
+
+
/* opcode base adjustment handler */
-typedef offs_t (*opbase_handler_func) (ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t address);
+typedef offs_t (*opbase_handler_func) (ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t address, ATTR_UNUSED opbase_data *opbase);
/* machine read/write handlers */
@@ -362,7 +375,7 @@ union _addrmap64_token
***************************************************************************/
/* opcode base adjustment handler function macro */
-#define OPBASE_HANDLER(name) offs_t name(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t address)
+#define OPBASE_HANDLER(name) offs_t name(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t address, opbase_data *opbase)
/* machine read/write handler function macros */
@@ -453,19 +466,19 @@ union _addrmap64_token
/* opcode range safety check */
-#define address_is_unsafe(A) ((UNEXPECTED((A) < opcode_memory_min) || UNEXPECTED((A) > opcode_memory_max)))
+#define address_is_unsafe(A) ((UNEXPECTED((A) < opbase.mem_min) || UNEXPECTED((A) > opbase.mem_max)))
/* unsafe opcode and opcode argument reading */
-#define cpu_opptr_unsafe(A) ((void *)&opcode_base[(A) & opcode_mask])
-#define cpu_readop_unsafe(A) (opcode_base[(A) & opcode_mask])
-#define cpu_readop16_unsafe(A) (*(UINT16 *)&opcode_base[(A) & opcode_mask])
-#define cpu_readop32_unsafe(A) (*(UINT32 *)&opcode_base[(A) & opcode_mask])
-#define cpu_readop64_unsafe(A) (*(UINT64 *)&opcode_base[(A) & opcode_mask])
-#define cpu_readop_arg_unsafe(A) (opcode_arg_base[(A) & opcode_mask])
-#define cpu_readop_arg16_unsafe(A) (*(UINT16 *)&opcode_arg_base[(A) & opcode_mask])
-#define cpu_readop_arg32_unsafe(A) (*(UINT32 *)&opcode_arg_base[(A) & opcode_mask])
-#define cpu_readop_arg64_unsafe(A) (*(UINT64 *)&opcode_arg_base[(A) & opcode_mask])
+#define cpu_opptr_unsafe(A) ((void *)&opbase.rom[(A) & opbase.mask])
+#define cpu_readop_unsafe(A) (opbase.rom[(A) & opbase.mask])
+#define cpu_readop16_unsafe(A) (*(UINT16 *)&opbase.rom[(A) & opbase.mask])
+#define cpu_readop32_unsafe(A) (*(UINT32 *)&opbase.rom[(A) & opbase.mask])
+#define cpu_readop64_unsafe(A) (*(UINT64 *)&opbase.rom[(A) & opbase.mask])
+#define cpu_readop_arg_unsafe(A) (opbase.ram[(A) & opbase.mask])
+#define cpu_readop_arg16_unsafe(A) (*(UINT16 *)&opbase.ram[(A) & opbase.mask])
+#define cpu_readop_arg32_unsafe(A) (*(UINT32 *)&opbase.ram[(A) & opbase.mask])
+#define cpu_readop_arg64_unsafe(A) (*(UINT64 *)&opbase.ram[(A) & opbase.mask])
/* wrappers for dynamic read handler installation */
@@ -800,12 +813,6 @@ union _addrmap64_token
GLOBAL VARIABLES
***************************************************************************/
-extern UINT8 opcode_entry; /* current entry for opcode fetching */
-extern UINT8 * opcode_base; /* opcode ROM base */
-extern UINT8 * opcode_arg_base; /* opcode RAM base */
-extern offs_t opcode_mask; /* mask to apply to the opcode address */
-extern offs_t opcode_memory_min; /* opcode memory minimum */
-extern offs_t opcode_memory_max; /* opcode memory maximum */
extern address_space active_address_space[]; /* address spaces */
extern const char *const address_space_names[ADDRESS_SPACES];
@@ -941,15 +948,15 @@ UINT32 cpu_readop_arg32_safe(offs_t byteaddress);
UINT64 cpu_readop_arg64_safe(offs_t byteaddress);
/* opcode and opcode argument reading */
-INLINE void * cpu_opptr(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_opptr_unsafe(byteaddress); }
-INLINE UINT8 cpu_readop(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop_unsafe(byteaddress); }
-INLINE UINT16 cpu_readop16(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop16_unsafe(byteaddress); }
-INLINE UINT32 cpu_readop32(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop32_unsafe(byteaddress); }
-INLINE UINT64 cpu_readop64(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop64_unsafe(byteaddress); }
-INLINE UINT8 cpu_readop_arg(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop_arg_unsafe(byteaddress); }
-INLINE UINT16 cpu_readop_arg16(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop_arg16_unsafe(byteaddress); }
-INLINE UINT32 cpu_readop_arg32(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop_arg32_unsafe(byteaddress); }
-INLINE UINT64 cpu_readop_arg64(offs_t byteaddress) { if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop_arg64_unsafe(byteaddress); }
+INLINE void * cpu_opptr(offs_t byteaddress) { extern opbase_data opbase; if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_opptr_unsafe(byteaddress); }
+INLINE UINT8 cpu_readop(offs_t byteaddress) { extern opbase_data opbase; if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop_unsafe(byteaddress); }
+INLINE UINT16 cpu_readop16(offs_t byteaddress) { extern opbase_data opbase; if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop16_unsafe(byteaddress); }
+INLINE UINT32 cpu_readop32(offs_t byteaddress) { extern opbase_data opbase; if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop32_unsafe(byteaddress); }
+INLINE UINT64 cpu_readop64(offs_t byteaddress) { extern opbase_data opbase; if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop64_unsafe(byteaddress); }
+INLINE UINT8 cpu_readop_arg(offs_t byteaddress) { extern opbase_data opbase; if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop_arg_unsafe(byteaddress); }
+INLINE UINT16 cpu_readop_arg16(offs_t byteaddress) { extern opbase_data opbase; if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop_arg16_unsafe(byteaddress); }
+INLINE UINT32 cpu_readop_arg32(offs_t byteaddress) { extern opbase_data opbase; if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop_arg32_unsafe(byteaddress); }
+INLINE UINT64 cpu_readop_arg64(offs_t byteaddress) { extern opbase_data opbase; if (address_is_unsafe(byteaddress)) { memory_set_opbase(byteaddress); } return cpu_readop_arg64_unsafe(byteaddress); }
/***************************************************************************
diff --git a/src/mame/drivers/atarig42.c b/src/mame/drivers/atarig42.c
index 5666703d850..87bdd990399 100644
--- a/src/mame/drivers/atarig42.c
+++ b/src/mame/drivers/atarig42.c
@@ -147,7 +147,7 @@ static OPBASE_HANDLER( sloop_opbase_handler )
{
if (address < 0x80000)
{
- opcode_base = opcode_arg_base = (void *)sloop_base;
+ opbase->rom = opbase->ram = (void *)sloop_base;
return (offs_t)-1;
}
return address;
diff --git a/src/mame/drivers/atarisy2.c b/src/mame/drivers/atarisy2.c
index b4e07651536..8ad3e459079 100644
--- a/src/mame/drivers/atarisy2.c
+++ b/src/mame/drivers/atarisy2.c
@@ -236,7 +236,7 @@ static OPBASE_HANDLER( atarisy2_opbase_handler )
/* make sure slapstic area looks like ROM */
if (address >= 0x8000 && address < 0x8200)
{
- opcode_base = opcode_arg_base = (UINT8 *)atarisy2_slapstic - 0x8000;
+ opbase->rom = opbase->ram = (UINT8 *)atarisy2_slapstic - 0x8000;
return ~0;
}
return address;
diff --git a/src/mame/drivers/cps3.c b/src/mame/drivers/cps3.c
index a657e0f7387..4d97f1c5eee 100644
--- a/src/mame/drivers/cps3.c
+++ b/src/mame/drivers/cps3.c
@@ -1355,31 +1355,31 @@ static OPBASE_HANDLER( cps3_opbase_handler )
/* BIOS ROM */
if (address < 0x80000)
{
- opcode_base = opcode_arg_base = memory_region(REGION_USER1);
+ opbase->rom = opbase->ram = memory_region(REGION_USER1);
return ~0;
}
/* RAM */
else if (address >= 0x06000000 && address <= 0x06ffffff)
{
- opcode_base = (UINT8*)decrypted_gamerom-0x06000000;
- opcode_arg_base = (UINT8*)decrypted_gamerom-0x06000000;
+ opbase->rom = (UINT8*)decrypted_gamerom-0x06000000;
+ opbase->ram = (UINT8*)decrypted_gamerom-0x06000000;
- if (cps3_isSpecial) opcode_arg_base = (UINT8*) memory_region(REGION_USER4)-0x06000000;
+ if (cps3_isSpecial) opbase->ram = (UINT8*) memory_region(REGION_USER4)-0x06000000;
return ~0;
}
else if (address >= 0xc0000000 && address <= 0xc00003ff)
{
-// opcode_base = (void*)cps3_0xc0000000_ram_decrypted;
- opcode_base = (UINT8*)cps3_0xc0000000_ram_decrypted-0xc0000000;
- opcode_arg_base = (UINT8*)cps3_0xc0000000_ram-0xc0000000;
+ //opbase->rom = (void*)cps3_0xc0000000_ram_decrypted;
+ opbase->rom = (UINT8*)cps3_0xc0000000_ram_decrypted-0xc0000000;
+ opbase->ram = (UINT8*)cps3_0xc0000000_ram-0xc0000000;
return ~0;
}
/* anything else falls through to NOPs */
- opcode_base = (UINT8*)cps3_nops-address;
- opcode_arg_base = (UINT8*)cps3_nops-address;
+ opbase->rom = (UINT8*)cps3_nops-address;
+ opbase->ram = (UINT8*)cps3_nops-address;
return ~0;
}
@@ -1704,17 +1704,8 @@ static void cps3_flashmain_w(int base, UINT32 offset, UINT32 data, UINT32 mem_ma
romdata[offset] = newdata;
romdata2[offset] = newdata^cps3_mask(0x6000000+real_offset, cps3_key1, cps3_key2);
}
-
-
-
-/*
- opcode_base = (UINT8*)decrypted_gamerom-0x06000000;
- opcode_arg_base = (UINT8*)decrypted_gamerom-0x06000000;
-
- if (cps3_isSpecial) opcode_arg_base = (UINT8*) memory_region(REGION_USER4)-0x06000000;
-*/
-
}
+
static WRITE32_HANDLER( cps3_flash1_w )
{
cps3_flashmain_w(0, offset,data,mem_mask);
diff --git a/src/mame/drivers/hng64.c b/src/mame/drivers/hng64.c
index 233c8368fd6..5deb2cc41a1 100644
--- a/src/mame/drivers/hng64.c
+++ b/src/mame/drivers/hng64.c
@@ -1072,7 +1072,7 @@ index=00000004 pagesize=01000000 vaddr=00000000C9000000 paddr=000000006900000
static OPBASE_HANDLER( KL5C80_opbase_handler )
{
- opcode_base = opcode_arg_base = hng64_com_op_base;
+ opbase->rom = opbase->ram = hng64_com_op_base;
return ~0;
}
diff --git a/src/mame/drivers/leland.c b/src/mame/drivers/leland.c
index 78b184d3f6c..76be1245ff1 100644
--- a/src/mame/drivers/leland.c
+++ b/src/mame/drivers/leland.c
@@ -1881,13 +1881,13 @@ static void dasm_chunk(char *tag, UINT8 *base, UINT16 pc, UINT32 length, FILE *o
{
extern unsigned DasmZ80(char *buffer, unsigned _pc);
- UINT8 *old_rom = opcode_base;
- UINT8 *old_ram = opcode_arg_base;
+ UINT8 *old_rom = opbase->rom;
+ UINT8 *old_ram = opbase->ram;
char buffer[256];
int count, offset, i;
fprintf(output, "\n\n\n%s:\n", tag);
- opcode_base = opcode_arg_base = &base[-pc];
+ opbase->rom = opbase->ram = &base[-pc];
for (offset = 0; offset < length; offset += count)
{
count = DasmZ80(buffer, pc);
@@ -1904,8 +1904,8 @@ static void dasm_chunk(char *tag, UINT8 *base, UINT16 pc, UINT32 length, FILE *o
fprintf(output, " ");
fprintf(output, "%s\n", buffer);
}
- opcode_base = old_rom;
- opcode_arg_base = old_ram;
+ opbase->rom = old_rom;
+ opbase->ram = old_ram;
}
#endif
diff --git a/src/mame/drivers/missile.c b/src/mame/drivers/missile.c
index 44fa90e255d..492eaca824f 100644
--- a/src/mame/drivers/missile.c
+++ b/src/mame/drivers/missile.c
@@ -365,14 +365,14 @@ static OPBASE_HANDLER( missile_opbase_handler )
/* RAM? */
if (address < 0x4000)
{
- opcode_base = opcode_arg_base = videoram - offset;
+ opbase->rom = opbase->ram = videoram - offset;
return ~0;
}
/* ROM? */
else if (address >= 0x5000)
{
- opcode_base = opcode_arg_base = memory_region(REGION_CPU1) - offset;
+ opbase->rom = opbase->ram = memory_region(REGION_CPU1) - offset;
return ~0;
}
@@ -389,7 +389,6 @@ static MACHINE_START( missile )
/* set up an opcode base handler since we use mapped handlers for RAM */
memory_set_opbase_handler(0, missile_opbase_handler);
- opcode_base = opcode_arg_base = videoram;
/* create a timer to speed/slow the CPU */
cpu_timer = timer_alloc(adjust_cpu_speed, NULL);
diff --git a/src/mame/machine/snes.c b/src/mame/machine/snes.c
index 4cc7dfcaefc..0f7e1c9479c 100644
--- a/src/mame/machine/snes.c
+++ b/src/mame/machine/snes.c
@@ -344,13 +344,13 @@ static void snes_init_ram(running_machine *machine)
/* should we treat this as nvram in MAME? */
static OPBASE_HANDLER(spc_opbase)
{
- opcode_base = opcode_arg_base = spc_ram;
+ opbase->rom = opbase->ram = spc_ram;
return ~0;
}
static OPBASE_HANDLER(snes_opbase)
{
- opcode_base = opcode_arg_base = snes_ram;
+ opbase->rom = opbase->ram = snes_ram;
return ~0;
}