summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2008-03-12 05:13:03 +0000
committer Aaron Giles <aaron@aarongiles.com>2008-03-12 05:13:03 +0000
commitd5561a8e755069f8d7b33e4597787c142ab9d06b (patch)
tree4ef36d5e2936f4b2b355012aee321848f2b12b25
parent61b009597e9083f88940b42bbce2a24faa2a2ca3 (diff)
Removed cpu_scalebyfcount().
Changed input ports to register a frame callback, which is called immediately after throttling and updating. This is the proper "sync point" between emulated time and real time. Moved all analog and digital port processing into a central place here. Added tracking of time since the previous frame update and use that as an estimate for the time of the current frame. This is used to scale analog ports without the use of cpu_scalebyfcount(). This is not perfect in the case where frame rates are dynamic (vector games), but works well for other cases. Further cleanup of memory header and code.
-rw-r--r--src/emu/cheat.c12
-rw-r--r--src/emu/cpuexec.c23
-rw-r--r--src/emu/deprecat.h3
-rw-r--r--src/emu/inptport.c117
-rw-r--r--src/emu/mame.c1
-rw-r--r--src/emu/memory.c123
-rw-r--r--src/emu/memory.h775
-rw-r--r--src/emu/validity.c2
-rw-r--r--src/mame/video/taitoic.c2
9 files changed, 512 insertions, 546 deletions
diff --git a/src/emu/cheat.c b/src/emu/cheat.c
index d9ceb968701..a3e19f06589 100644
--- a/src/emu/cheat.c
+++ b/src/emu/cheat.c
@@ -9010,7 +9010,7 @@ static void SetSearchRegionDefaultName(SearchRegion * region)
if(region->writeHandler)
{
- genf * handler = region->writeHandler->write.handler;
+ genf * handler = region->writeHandler->write.generic;
FPTR handlerAddress = (FPTR)handler;
if( (handlerAddress >= ((FPTR)SMH_BANK1)) && (handlerAddress <= ((FPTR)SMH_BANK24)))
@@ -9159,9 +9159,9 @@ static void BuildSearchRegions(running_machine *machine, SearchInfo * info)
SearchRegion * traverse;
int count = 0;
- map = memory_get_map(info->targetIdx, ADDRESS_SPACE_PROGRAM);
+ map = memory_get_address_map(info->targetIdx, ADDRESS_SPACE_PROGRAM);
for (entry = map->entrylist; entry != NULL; entry = entry->next)
- if (entry->write.handler)
+ if (entry->write.generic)
count++;
info->regionList = calloc(sizeof(SearchRegion), count);
@@ -9170,7 +9170,7 @@ static void BuildSearchRegions(running_machine *machine, SearchInfo * info)
for (entry = map->entrylist; entry != NULL; entry = entry->next)
{
- if (entry->write.handler)
+ if (entry->write.generic)
{
UINT32 length = (entry->addrend - entry->addrstart) + 1;
@@ -10466,11 +10466,11 @@ static void DoSearch(SearchInfo * search)
static UINT8 ** LookupHandlerMemory(UINT8 cpu, UINT32 address, UINT32 * outRelativeAddress)
{
- const address_map * map = memory_get_map(cpu, ADDRESS_SPACE_PROGRAM);
+ const address_map * map = memory_get_address_map(cpu, ADDRESS_SPACE_PROGRAM);
const address_map_entry *entry;
for (entry = map->entrylist; entry != NULL; entry = entry->next)
- if (entry->write.handler != NULL && (address >= entry->addrstart) && (address <= entry->addrend))
+ if (entry->write.generic != NULL && (address >= entry->addrstart) && (address <= entry->addrend))
{
if(outRelativeAddress)
*outRelativeAddress = address - entry->addrstart;
diff --git a/src/emu/cpuexec.c b/src/emu/cpuexec.c
index bc2d034536c..31e6ce2f930 100644
--- a/src/emu/cpuexec.c
+++ b/src/emu/cpuexec.c
@@ -742,29 +742,6 @@ void cpu_triggerint(running_machine *machine, int cpunum)
***************************************************************************/
/*-------------------------------------------------
- cpu_scalebyfcount - scale by time between
- refresh timers
--------------------------------------------------*/
-
-int cpu_scalebyfcount(int value)
-{
-// attotime refresh_elapsed = timer_timeelapsed(refresh_timer);
-// int result;
-
- /* shift off some bits to ensure no overflow */
-// if (value < 65536)
-// result = value * (refresh_elapsed.attoseconds >> 16) / (refresh_period.attoseconds >> 16);
-// else
-// result = value * (refresh_elapsed.attoseconds >> 32) / (refresh_period.attoseconds >> 32);
-// if (value >= 0)
-// return (result < value) ? result : value;
-// else
-// return (result > value) ? result : value;
- return 0;
-}
-
-
-/*-------------------------------------------------
cpu_getiloops - return the cheesy VBLANK
interrupt counter (deprecated)
-------------------------------------------------*/
diff --git a/src/emu/deprecat.h b/src/emu/deprecat.h
index 9f25f95ae21..e01b74676ad 100644
--- a/src/emu/deprecat.h
+++ b/src/emu/deprecat.h
@@ -65,8 +65,5 @@ extern running_machine *Machine;
that the interrupt handler will be called once. */
int cpu_getiloops(void);
-/* Scales a given value by the ratio of fcount / fperiod */
-int cpu_scalebyfcount(int value);
-
#endif /* __DEPRECAT_H__ */
diff --git a/src/emu/inptport.c b/src/emu/inptport.c
index d428032bb9e..0b2c8a75a77 100644
--- a/src/emu/inptport.c
+++ b/src/emu/inptport.c
@@ -265,6 +265,8 @@ static double rec_speed;
static int extended_inp;
/* for average speed calculations */
+static attotime last_update;
+static attoseconds_t last_delta;
static int framecount;
static double totalspeed;
@@ -1032,14 +1034,12 @@ static int default_ports_lookup[__ipt_max][MAX_PLAYERS];
FUNCTION PROTOTYPES
***************************************************************************/
-static void on_vblank(running_machine *machine, int vblank_state);
static void setup_playback(running_machine *machine);
static void setup_record(running_machine *machine);
static void input_port_exit(running_machine *machine);
+static void input_port_frame(running_machine *machine);
static void input_port_load(int config_type, xml_data_node *parentnode);
static void input_port_save(int config_type, xml_data_node *parentnode);
-static void input_port_vblank_start(running_machine *machine);
-static void input_port_vblank_end(void);
static void update_digital_joysticks(void);
static void update_analog_port(int port);
static void interpolate_analog_port(int port);
@@ -1063,6 +1063,7 @@ void input_port_init(running_machine *machine, const input_port_token *ipt)
/* add an exit callback */
add_exit_callback(machine, input_port_exit);
+ add_frame_callback(machine, input_port_frame);
/* start with the raw defaults and ask the OSD to customize them in the backup array */
memcpy(default_ports_backup, default_ports_builtin, sizeof(default_ports_backup));
@@ -1139,32 +1140,6 @@ void input_port_init(running_machine *machine, const input_port_token *ipt)
}
-void input_port_post_init(running_machine *machine)
-{
- /* set up callback for updating the ports */
- video_screen_register_global_vbl_cb(on_vblank);
-}
-
-
-
-/*************************************
- *
- * VBLANK handler
- *
- *************************************/
-
-static void on_vblank(running_machine *machine, int vblank_state)
-{
- /* VBLANK starting - read keyboard & update the status of the input ports */
- if (vblank_state)
- input_port_vblank_start(machine);
-
- /* VBLANK ending - update IPT_VBLANK input ports */
- else
- input_port_vblank_end();
-}
-
-
/*************************************
*
@@ -1539,7 +1514,7 @@ static void input_port_postload(void)
}
/* run an initial update */
- input_port_vblank_start(Machine);
+ input_port_frame(Machine);
}
@@ -2799,22 +2774,22 @@ profiler_mark(PROFILER_END);
*
*************************************/
-static void update_playback_record(int portnum, UINT32 portvalue)
+static void update_playback_record(running_machine *machine, int portnum, UINT32 portvalue)
{
/* handle playback */
- if (Machine->playback_file != NULL)
+ if (machine->playback_file != NULL)
{
UINT32 result;
/* a successful read goes into the playback field which overrides everything else */
- if (mame_fread(Machine->playback_file, &result, sizeof(result)) == sizeof(result))
+ if (mame_fread(machine->playback_file, &result, sizeof(result)) == sizeof(result))
portvalue = port_info[portnum].playback = BIG_ENDIANIZE_INT32(result);
/* a failure causes us to close the playback file and stop playback */
else
{
- mame_fclose(Machine->playback_file);
- Machine->playback_file = NULL;
+ mame_fclose(machine->playback_file);
+ machine->playback_file = NULL;
if (!extended_inp)
popmessage("End of playback");
else
@@ -2826,19 +2801,19 @@ static void update_playback_record(int portnum, UINT32 portvalue)
}
/* handle recording */
- if (Machine->record_file != NULL)
+ if (machine->record_file != NULL)
{
UINT32 result = BIG_ENDIANIZE_INT32(portvalue);
/* a successful write just works */
- if (mame_fwrite(Machine->record_file, &result, sizeof(result)) == sizeof(result))
+ if (mame_fwrite(machine->record_file, &result, sizeof(result)) == sizeof(result))
;
/* a failure causes us to close the record file and stop recording */
else
{
- mame_fclose(Machine->record_file);
- Machine->record_file = NULL;
+ mame_fclose(machine->record_file);
+ machine->record_file = NULL;
}
}
}
@@ -2884,13 +2859,23 @@ void input_port_update_defaults(void)
*
*************************************/
-static void input_port_vblank_start(running_machine *machine)
+static void input_port_frame(running_machine *machine)
{
int ui_visible = ui_is_menu_active() || ui_is_slider_active();
+ attotime curtime = timer_get_time();
int portnum, bitnum;
profiler_mark(PROFILER_INPUT);
+ /* track the duration of the previous frame */
+ last_delta = attotime_to_attoseconds(attotime_sub(curtime, last_update)) / ATTOSECONDS_PER_SECOND_SQRT;
+ last_update = curtime;
+
+ /* update all analog ports if the UI isn't visible */
+ if (!ui_visible)
+ for (portnum = 0; portnum < MAX_INPUT_PORTS; portnum++)
+ update_analog_port(portnum);
+
/* update the digital joysticks first */
update_digital_joysticks();
@@ -2958,15 +2943,15 @@ profiler_mark(PROFILER_INPUT);
UINT8 mask;
switch( port->way )
{
- case 4:
- mask = joyinfo->current4way;
- break;
- case 16:
- mask = 0xff;
- break;
- default:
- mask = joyinfo->current;
- break;
+ case 4:
+ mask = joyinfo->current4way;
+ break;
+ case 16:
+ mask = 0xff;
+ break;
+ default:
+ mask = joyinfo->current;
+ break;
}
if ((mask >> JOYSTICK_DIR_FOR_PORT(port)) & 1)
portinfo->digital ^= port->mask;
@@ -3025,7 +3010,7 @@ profiler_mark(PROFILER_INPUT);
/* non-analog ports must be manually updated */
else
- update_playback_record(portnum, readinputport(portnum));
+ update_playback_record(machine, portnum, readinputport(portnum));
}
/* store speed read from INP file, if extended INP */
@@ -3046,29 +3031,6 @@ profiler_mark(PROFILER_END);
/*************************************
*
- * VBLANK end routine
- *
- *************************************/
-
-static void input_port_vblank_end(void)
-{
- int ui_visible = ui_is_menu_active() || ui_is_slider_active();
- int port;
-
-profiler_mark(PROFILER_INPUT);
-
- /* update all analog ports if the UI isn't visible */
- if (!ui_visible)
- for (port = 0; port < MAX_INPUT_PORTS; port++)
- update_analog_port(port);
-
-profiler_mark(PROFILER_END);
-}
-
-
-
-/*************************************
- *
* Digital joystick updating
*
*************************************/
@@ -3380,8 +3342,11 @@ profiler_mark(PROFILER_INPUT);
INT32 value;
/* interpolate or not */
- if (info->interpolate && !port->analog.reset)
- current = info->previous + cpu_scalebyfcount(info->accum - info->previous);
+ if (info->interpolate && !port->analog.reset && last_delta != 0)
+ {
+ attoseconds_t time_since_last = attotime_to_attoseconds(attotime_sub(timer_get_time(), last_update)) / ATTOSECONDS_PER_SECOND_SQRT;
+ current = info->previous + ((INT64)(info->accum - info->previous) * time_since_last / last_delta);
+ }
else
current = info->accum;
@@ -3457,7 +3422,7 @@ UINT32 readinputport(int port)
/* if we have analog data, update the recording state */
if (port_info[port].analoginfo)
- update_playback_record(port, result);
+ update_playback_record(Machine, port, result);
/* if we're playing back, use the recorded value for inputs instead */
if (Machine->playback_file != NULL)
diff --git a/src/emu/mame.c b/src/emu/mame.c
index 805ab371cd5..8887e583f0e 100644
--- a/src/emu/mame.c
+++ b/src/emu/mame.c
@@ -1585,7 +1585,6 @@ static void init_machine(running_machine *machine)
crosshair_init(machine);
sound_init(machine);
- input_port_post_init(machine);
#ifdef ENABLE_DEBUGGER
/* initialize the debugger */
diff --git a/src/emu/memory.c b/src/emu/memory.c
index 6ec1f9f0d42..396c4b72760 100644
--- a/src/emu/memory.c
+++ b/src/emu/memory.c
@@ -167,7 +167,7 @@ typedef enum _read_or_write read_or_write;
MACROS
***************************************************************************/
-/* ----- table lookup helpers ----- */
+/* table lookup helpers */
#define LEVEL1_INDEX(a) ((a) >> LEVEL2_BITS)
#define LEVEL2_INDEX(e,a) ((1 << LEVEL1_BITS) + (((e) - SUBTABLE_BASE) << LEVEL2_BITS) + ((a) & ((1 << LEVEL2_BITS) - 1)))
@@ -236,23 +236,15 @@ struct _bank_data
void * entryd[MAX_BANK_ENTRIES];/* array of decrypted entries for this bank */
};
-typedef union _rwhandlers rwhandlers;
-union _rwhandlers
-{
- genf * generic; /* generic handler void */
- read_handlers read; /* read handlers */
- write_handlers write; /* write handlers */
-};
-
/* In memory.h: typedef struct _handler_data handler_data */
struct _handler_data
{
- rwhandlers handler; /* function pointer for handler */
+ memory_handler handler; /* function pointer for handler */
+ void * object; /* object associated with the handler */
+ const char * name; /* name of the handler */
offs_t bytestart; /* byte-adjusted start address for handler */
offs_t byteend; /* byte-adjusted end address for handler */
offs_t bytemask; /* byte-adjusted mask against the final address */
- void * object; /* object associated with the handler */
- const char * name; /* name of the handler */
};
typedef struct _subtable_data subtable_data;
@@ -490,24 +482,23 @@ INLINE void adjust_addresses(addrspace_data *space, offs_t *start, offs_t *end,
void memory_init(running_machine *machine)
{
- int i;
+ int spacenum;
- for (i = 0; i < ADDRESS_SPACES; i++)
- log_unmap[i] = TRUE;
+ add_exit_callback(machine, memory_exit);
- /* no current context to start */
+ /* reset globals */
cur_context = -1;
+ for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++)
+ log_unmap[spacenum] = TRUE;
/* reset the shared pointers and bank pointers */
memset(shared_ptr, 0, sizeof(shared_ptr));
memset(bank_ptr, 0, sizeof(bank_ptr));
memset(bankd_ptr, 0, sizeof(bankd_ptr));
- /* init the CPUs */
+ /* build up the cpudata array with info about all CPUs and address spaces */
memory_init_cpudata(machine->config);
- add_exit_callback(machine, memory_exit);
-
/* preflight the memory handlers and check banks */
memory_init_preflight(machine->config);
@@ -640,17 +631,6 @@ const data_accessors *memory_get_accessors(int spacenum, int databits, int endia
/*-------------------------------------------------
- memory_get_map - return a pointer to a CPU's
- memory map
--------------------------------------------------*/
-
-const address_map *memory_get_map(int cpunum, int spacenum)
-{
- return cpudata[cpunum].space[spacenum].map;
-}
-
-
-/*-------------------------------------------------
memory_set_opbase_handler - change op-code
memory base
-------------------------------------------------*/
@@ -1185,7 +1165,7 @@ UINT64 *_memory_install_readwrite64_handler(int cpunum, int spacenum, offs_t add
/*-------------------------------------------------
address_map_alloc - build and allocate an
- address map
+ address map for a CPU's address space
-------------------------------------------------*/
address_map *address_map_alloc(const machine_config *config, int cpunum, int spacenum)
@@ -1232,6 +1212,18 @@ void address_map_free(address_map *map)
/*-------------------------------------------------
+ memory_get_address_map - return a pointer to
+ the constructed address map for a CPU's
+ address space
+-------------------------------------------------*/
+
+const address_map *memory_get_address_map(int cpunum, int spacenum)
+{
+ return cpudata[cpunum].space[spacenum].map;
+}
+
+
+/*-------------------------------------------------
address_map_detokenize - detokenize an array
of address map tokens
-------------------------------------------------*/
@@ -1504,7 +1496,7 @@ static void memory_init_preflight(const machine_config *config)
adjust_addresses(space, &entry->bytestart, &entry->byteend, &entry->bytemask, &entry->bytemirror);
/* if this is a ROM handler without a specified region, attach it to the implicit region */
- if (spacenum == ADDRESS_SPACE_PROGRAM && HANDLER_IS_ROM(entry->read.handler) && entry->region == 0)
+ if (spacenum == ADDRESS_SPACE_PROGRAM && HANDLER_IS_ROM(entry->read.generic) && entry->region == 0)
{
/* make sure it fits within the memory region before doing so, however */
if (entry->byteend < cpu->regionsize)
@@ -1532,10 +1524,10 @@ static void memory_init_preflight(const machine_config *config)
entry->memory = memory_region(entry->region) + entry->region_offs;
/* assign static banks for explicitly specified entries */
- if (HANDLER_IS_BANK(entry->read.handler))
- bank_assign_static(HANDLER_TO_BANK(entry->read.handler), cpunum, spacenum, ROW_READ, entry->bytestart, entry->byteend);
- if (HANDLER_IS_BANK(entry->write.handler))
- bank_assign_static(HANDLER_TO_BANK(entry->write.handler), cpunum, spacenum, ROW_WRITE, entry->bytestart, entry->byteend);
+ if (HANDLER_IS_BANK(entry->read.generic))
+ bank_assign_static(HANDLER_TO_BANK(entry->read.generic), cpunum, spacenum, ROW_READ, entry->bytestart, entry->byteend);
+ if (HANDLER_IS_BANK(entry->write.generic))
+ bank_assign_static(HANDLER_TO_BANK(entry->write.generic), cpunum, spacenum, ROW_WRITE, entry->bytestart, entry->byteend);
}
/* now loop over all the handlers and enforce the address mask */
@@ -1579,7 +1571,7 @@ static void memory_init_populate(running_machine *machine)
for (entry = space->map->entrylist; entry->next != last_entry; entry = entry->next) ;
last_entry = entry;
- if (entry->read.handler != NULL)
+ if (entry->read.generic != NULL)
{
void *object = machine;
if (entry->read_devtype != NULL)
@@ -1588,9 +1580,9 @@ static void memory_init_populate(running_machine *machine)
if (object == NULL)
fatalerror("Unidentified object in memory map: type=%s tag=%s\n", devtype_name(entry->read_devtype), entry->read_devtag);
}
- install_mem_handler_private(space, ROW_READ, space->dbits, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, entry->read.handler, object, entry->read_name);
+ install_mem_handler_private(space, ROW_READ, space->dbits, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, entry->read.generic, object, entry->read_name);
}
- if (entry->write.handler != NULL)
+ if (entry->write.generic != NULL)
{
void *object = machine;
if (entry->write_devtype != NULL)
@@ -1599,7 +1591,7 @@ static void memory_init_populate(running_machine *machine)
if (object == NULL)
fatalerror("Unidentified object in memory map: type=%s tag=%s\n", devtype_name(entry->write_devtype), entry->write_devtag);
}
- install_mem_handler_private(space, ROW_WRITE, space->dbits, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, entry->write.handler, object, entry->write_name);
+ install_mem_handler_private(space, ROW_WRITE, space->dbits, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, entry->write.generic, object, entry->write_name);
}
}
}
@@ -1815,40 +1807,45 @@ static genf *bank_assign_dynamic(int cpunum, int spacenum, read_or_write readorw
static UINT8 get_handler_index(handler_data *table, void *object, genf *handler, const char *handler_name, offs_t bytestart, offs_t byteend, offs_t bytemask)
{
- int i;
-
- bytestart &= bytemask;
+ int entry;
/* all static handlers are hardcoded */
if (HANDLER_IS_STATIC(handler))
{
- i = (FPTR)handler;
+ entry = (FPTR)handler;
+
+ /* if it is a bank, copy in the relevant information */
if (HANDLER_IS_BANK(handler))
{
- table[i].bytestart = bytestart;
- table[i].byteend = byteend;
- table[i].bytemask = bytemask;
- table[i].name = handler_name;
- table[i].object = object;
+ handler_data *hdata = &table[entry];
+ hdata->bytestart = bytestart;
+ hdata->byteend = byteend;
+ hdata->bytemask = bytemask;
+ hdata->name = handler_name;
}
- return i;
+ return entry;
}
/* otherwise, we have to search */
- for (i = STATIC_COUNT; i < SUBTABLE_BASE; i++)
+ for (entry = STATIC_COUNT; entry < SUBTABLE_BASE; entry++)
{
- if (table[i].handler.generic == NULL)
+ handler_data *hdata = &table[entry];
+
+ /* if we hit a NULL hdata, then we need to allocate this one as a new one */
+ if (hdata->handler.generic == NULL)
{
- table[i].handler.generic = handler;
- table[i].bytestart = bytestart;
- table[i].byteend = byteend;
- table[i].bytemask = bytemask;
- table[i].name = handler_name;
- table[i].object = object;
- return i;
+ hdata->handler.generic = handler;
+ hdata->bytestart = bytestart;
+ hdata->byteend = byteend;
+ hdata->bytemask = bytemask;
+ hdata->name = handler_name;
+ hdata->object = object;
+ return entry;
}
- if (table[i].handler.generic == handler && table[i].bytestart == bytestart && table[i].bytemask == bytemask && table[i].object == object)
- return i;
+
+ /* if we find a perfect match, return a duplicate entry */
+ if (hdata->handler.generic == handler && hdata->bytestart == bytestart && hdata->bytemask == bytemask && hdata->object == object)
+ return entry;
}
return 0;
}
@@ -2121,7 +2118,7 @@ static int amentry_needs_backing_store(int cpunum, int spacenum, const address_m
if (entry->baseptr != NULL || entry->baseptroffs_plus1 != 0)
return 1;
- handler = (FPTR)entry->write.handler;
+ handler = (FPTR)entry->write.generic;
if (handler < STATIC_COUNT)
{
if (handler != STATIC_INVALID &&
@@ -2131,7 +2128,7 @@ static int amentry_needs_backing_store(int cpunum, int spacenum, const address_m
return 1;
}
- handler = (FPTR)entry->read.handler;
+ handler = (FPTR)entry->read.generic;
if (handler < STATIC_COUNT)
{
if (handler != STATIC_INVALID &&
diff --git a/src/emu/memory.h b/src/emu/memory.h
index a744bc5e7a5..63a0c6287dd 100644
--- a/src/emu/memory.h
+++ b/src/emu/memory.h
@@ -19,303 +19,242 @@
#include "tokenize.h"
-
/***************************************************************************
- BASIC TYPE DEFINITIONS
+ CONSTANTS
***************************************************************************/
-/* ----- typedefs for data and offset types ----- */
-typedef UINT32 offs_t;
-
-/* ----- typedefs for the various common data access handlers ----- */
-typedef UINT8 (*read8_machine_func) (ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset);
-typedef void (*write8_machine_func) (ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT8 data);
-typedef UINT16 (*read16_machine_func) (ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 mem_mask);
-typedef void (*write16_machine_func)(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 data, ATTR_UNUSED UINT16 mem_mask);
-typedef UINT32 (*read32_machine_func) (ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 mem_mask);
-typedef void (*write32_machine_func)(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 data, ATTR_UNUSED UINT32 mem_mask);
-typedef UINT64 (*read64_machine_func) (ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 mem_mask);
-typedef void (*write64_machine_func)(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 data, ATTR_UNUSED UINT64 mem_mask);
-
-typedef UINT8 (*read8_device_func) (ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset);
-typedef void (*write8_device_func) (ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT8 data);
-typedef UINT16 (*read16_device_func) (ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 mem_mask);
-typedef void (*write16_device_func)(ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 data, ATTR_UNUSED UINT16 mem_mask);
-typedef UINT32 (*read32_device_func) (ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 mem_mask);
-typedef void (*write32_device_func)(ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 data, ATTR_UNUSED UINT32 mem_mask);
-typedef UINT64 (*read64_device_func) (ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 mem_mask);
-typedef void (*write64_device_func)(ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 data, ATTR_UNUSED UINT64 mem_mask);
-
-typedef offs_t (*opbase_handler_func) (ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t address);
-
-/* ----- this struct contains pointers to the live read/write routines ----- */
-typedef struct _data_accessors data_accessors;
-struct _data_accessors
+/* address spaces */
+enum
{
- void (*change_pc)(offs_t byteaddress);
-
- UINT8 (*read_byte)(offs_t byteaddress);
- UINT16 (*read_word)(offs_t byteaddress);
- UINT32 (*read_dword)(offs_t byteaddress);
- UINT32 (*read_dword_masked)(offs_t byteaddress, UINT32 mask);
- UINT64 (*read_qword)(offs_t byteaddress);
- UINT64 (*read_qword_masked)(offs_t byteaddress, UINT64 mask);
-
- void (*write_byte)(offs_t byteaddress, UINT8 data);
- void (*write_word)(offs_t byteaddress, UINT16 data);
- void (*write_dword)(offs_t byteaddress, UINT32 data);
- void (*write_dword_masked)(offs_t byteaddress, UINT32 data, UINT32 mask);
- void (*write_qword)(offs_t byteaddress, UINT64 data);
- void (*write_qword_masked)(offs_t byteaddress, UINT64 data, UINT64 mask);
+ ADDRESS_SPACE_PROGRAM = 0, /* program address space */
+ ADDRESS_SPACE_DATA, /* data address space */
+ ADDRESS_SPACE_IO, /* I/O address space */
+ ADDRESS_SPACES /* maximum number of address spaces */
};
+/* static data access handler constants */
+enum
+{
+ STATIC_INVALID = 0, /* invalid - should never be used */
+ STATIC_BANK1 = 1, /* first memory bank */
+ /* entries 1-32 are for fixed banks 1-32 specified by the driver */
+ /* entries 33-67 are for dynamically allocated internal banks */
+ STATIC_BANKMAX = 67, /* last memory bank */
+ STATIC_RAM, /* RAM - reads/writes map to dynamic banks */
+ STATIC_ROM, /* ROM - reads = RAM; writes = UNMAP */
+ STATIC_NOP, /* NOP - reads = unmapped value; writes = no-op */
+ STATIC_UNMAP, /* unmapped - same as NOP except we log errors */
+ STATIC_COUNT /* total number of static handlers */
+};
-/***************************************************************************
- BASIC MACROS
-***************************************************************************/
-
-/* ----- macros for declaring the various common data access handlers ----- */
-#define READ8_HANDLER(name) UINT8 name(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset)
-#define WRITE8_HANDLER(name) void name(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT8 data)
-#define READ16_HANDLER(name) UINT16 name(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 mem_mask)
-#define WRITE16_HANDLER(name) void name(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 data, ATTR_UNUSED UINT16 mem_mask)
-#define READ32_HANDLER(name) UINT32 name(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 mem_mask)
-#define WRITE32_HANDLER(name) void name(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 data, ATTR_UNUSED UINT32 mem_mask)
-#define READ64_HANDLER(name) UINT64 name(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 mem_mask)
-#define WRITE64_HANDLER(name) void name(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 data, ATTR_UNUSED UINT64 mem_mask)
-#define READ8_DEVICE_HANDLER(name) UINT8 name(ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset)
-#define WRITE8_DEVICE_HANDLER(name) void name(ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT8 data)
-#define READ16_DEVICE_HANDLER(name) UINT16 name(ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 mem_mask)
-#define WRITE16_DEVICE_HANDLER(name) void name(ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 data, ATTR_UNUSED UINT16 mem_mask)
-#define READ32_DEVICE_HANDLER(name) UINT32 name(ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 mem_mask)
-#define WRITE32_DEVICE_HANDLER(name) void name(ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 data, ATTR_UNUSED UINT32 mem_mask)
-#define READ64_DEVICE_HANDLER(name) UINT64 name(ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 mem_mask)
-#define WRITE64_DEVICE_HANDLER(name) void name(ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 data, ATTR_UNUSED UINT64 mem_mask)
+/* address map tokens */
+enum
+{
+ ADDRMAP_TOKEN_INVALID,
-#define OPBASE_HANDLER(name) offs_t name(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t address)
+ ADDRMAP_TOKEN_START,
+ ADDRMAP_TOKEN_END,
+ ADDRMAP_TOKEN_INCLUDE,
+
+ ADDRMAP_TOKEN_GLOBAL_MASK,
+ ADDRMAP_TOKEN_UNMAP_VALUE,
-/* ----- macros for accessing bytes and words within larger chunks ----- */
-#ifdef LSB_FIRST
- #define BYTE_XOR_BE(a) ((a) ^ 1) /* read/write a byte to a 16-bit space */
- #define BYTE_XOR_LE(a) (a)
- #define BYTE4_XOR_BE(a) ((a) ^ 3) /* read/write a byte to a 32-bit space */
- #define BYTE4_XOR_LE(a) (a)
- #define WORD_XOR_BE(a) ((a) ^ 2) /* read/write a word to a 32-bit space */
- #define WORD_XOR_LE(a) (a)
- #define BYTE8_XOR_BE(a) ((a) ^ 7) /* read/write a byte to a 64-bit space */
- #define BYTE8_XOR_LE(a) (a)
- #define WORD2_XOR_BE(a) ((a) ^ 6) /* read/write a word to a 64-bit space */
- #define WORD2_XOR_LE(a) (a)
- #define DWORD_XOR_BE(a) ((a) ^ 4) /* read/write a dword to a 64-bit space */
- #define DWORD_XOR_LE(a) (a)
-#else
- #define BYTE_XOR_BE(a) (a)
- #define BYTE_XOR_LE(a) ((a) ^ 1) /* read/write a byte to a 16-bit space */
- #define BYTE4_XOR_BE(a) (a)
- #define BYTE4_XOR_LE(a) ((a) ^ 3) /* read/write a byte to a 32-bit space */
- #define WORD_XOR_BE(a) (a)
- #define WORD_XOR_LE(a) ((a) ^ 2) /* read/write a word to a 32-bit space */
- #define BYTE8_XOR_BE(a) (a)
- #define BYTE8_XOR_LE(a) ((a) ^ 7) /* read/write a byte to a 64-bit space */
- #define WORD2_XOR_BE(a) (a)
- #define WORD2_XOR_LE(a) ((a) ^ 6) /* read/write a word to a 64-bit space */
- #define DWORD_XOR_BE(a) (a)
- #define DWORD_XOR_LE(a) ((a) ^ 4) /* read/write a dword to a 64-bit space */
-#endif
+ ADDRMAP_TOKEN_RANGE,
+ ADDRMAP_TOKEN_MASK,
+ ADDRMAP_TOKEN_MIRROR,
+ ADDRMAP_TOKEN_READ,
+ ADDRMAP_TOKEN_WRITE,
+ ADDRMAP_TOKEN_DEVICE_READ,
+ ADDRMAP_TOKEN_DEVICE_WRITE,
+ ADDRMAP_TOKEN_READ_PORT,
+ ADDRMAP_TOKEN_REGION,
+ ADDRMAP_TOKEN_SHARE,
+ ADDRMAP_TOKEN_BASEPTR,
+ ADDRMAP_TOKEN_BASE_MEMBER,
+ ADDRMAP_TOKEN_SIZEPTR,
+ ADDRMAP_TOKEN_SIZE_MEMBER
+};
/***************************************************************************
- ADDRESS ARRAY CONSTANTS
-****************************************************************************
- These apply to values in the array of read/write handlers that is
- declared within each driver.
+ TYPE DEFINITIONS
***************************************************************************/
-/* ----- static data access handler constants ----- */
-enum
-{
- STATIC_INVALID = 0, /* invalid - should never be used */
- STATIC_BANK1 = 1, /* banked memory */
- /* entries 1-32 are for fixed banks specified by the driver */
- /* entries 33-67 are for dynamically allocated internal banks */
- STATIC_RAM = 68, /* RAM - standard reads/writes */
- STATIC_ROM, /* ROM - standard reads, no writes */
- STATIC_NOP, /* NOP - reads return unmapped value; writes do nothing */
- STATIC_UNMAP, /* unmapped - all unmapped memory goes here */
- STATIC_COUNT /* total number of static handlers */
-};
+/* handler_data is an opaque type used to hold information about a particular handler */
+typedef struct _handler_data handler_data;
-/* ----- banking constants ----- */
-#define STATIC_BANKMAX (STATIC_RAM - 1) /* handler constant of last bank */
-
-/* SMH_* macros are Static Memory Handler definitions with
- pre-cast versions of the STATIC_* functions */
-#define SMH_RAM ((void *)STATIC_RAM)
-#define SMH_ROM ((void *)STATIC_ROM)
-#define SMH_NOP ((void *)STATIC_NOP)
-#define SMH_UNMAP ((void *)STATIC_UNMAP)
-#define SMH_BANK(n) ((void *)(STATIC_BANK1 + (n) - 1))
-
-#define SMH_BANK1 SMH_BANK(1)
-#define SMH_BANK2 SMH_BANK(2)
-#define SMH_BANK3 SMH_BANK(3)
-#define SMH_BANK4 SMH_BANK(4)
-#define SMH_BANK5 SMH_BANK(5)
-#define SMH_BANK6 SMH_BANK(6)
-#define SMH_BANK7 SMH_BANK(7)
-#define SMH_BANK8 SMH_BANK(8)
-#define SMH_BANK9 SMH_BANK(9)
-#define SMH_BANK10 SMH_BANK(10)
-#define SMH_BANK11 SMH_BANK(11)
-#define SMH_BANK12 SMH_BANK(12)
-#define SMH_BANK13 SMH_BANK(13)
-#define SMH_BANK14 SMH_BANK(14)
-#define SMH_BANK15 SMH_BANK(15)
-#define SMH_BANK16 SMH_BANK(16)
-#define SMH_BANK17 SMH_BANK(17)
-#define SMH_BANK18 SMH_BANK(18)
-#define SMH_BANK19 SMH_BANK(19)
-#define SMH_BANK20 SMH_BANK(20)
-#define SMH_BANK21 SMH_BANK(21)
-#define SMH_BANK22 SMH_BANK(22)
-#define SMH_BANK23 SMH_BANK(23)
-#define SMH_BANK24 SMH_BANK(24)
-#define SMH_BANK25 SMH_BANK(25)
-#define SMH_BANK26 SMH_BANK(26)
-#define SMH_BANK27 SMH_BANK(27)
-#define SMH_BANK28 SMH_BANK(28)
-#define SMH_BANK29 SMH_BANK(29)
-#define SMH_BANK30 SMH_BANK(30)
-#define SMH_BANK31 SMH_BANK(31)
-#define SMH_BANK32 SMH_BANK(32)
+/* offsets and addresses are 32-bit (for now...) */
+typedef UINT32 offs_t;
-/***************************************************************************
- ADDRESS SPACE ARRAY TYPE DEFINITIONS
-****************************************************************************
- Note that the data access handlers are not passed the actual address
- where the operation takes place, but the offset from the beginning
- of the block they are assigned to. This makes handling of mirror
- addresses easier, and makes the handlers a bit more "object oriented".
- If you handler needs to read/write the main memory area, provide a
- "base" pointer: it will be initialized by the main engine to point to
- the beginning of the memory block assigned to the handler. You may
- also provide a pointer to "size": it will be set to the length of
- the memory area processed by the handler.
-***************************************************************************/
+/* opcode base adjustment handler */
+typedef offs_t (*opbase_handler_func) (ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t address);
-typedef struct _handler_data handler_data;
-/* ----- a union of all the different read handler types ----- */
-typedef union _read_handlers read_handlers;
-union _read_handlers
+/* machine read/write handlers */
+typedef UINT8 (*read8_machine_func) (ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset);
+typedef void (*write8_machine_func) (ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT8 data);
+typedef UINT16 (*read16_machine_func) (ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 mem_mask);
+typedef void (*write16_machine_func)(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 data, ATTR_UNUSED UINT16 mem_mask);
+typedef UINT32 (*read32_machine_func) (ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 mem_mask);
+typedef void (*write32_machine_func)(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 data, ATTR_UNUSED UINT32 mem_mask);
+typedef UINT64 (*read64_machine_func) (ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 mem_mask);
+typedef void (*write64_machine_func)(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 data, ATTR_UNUSED UINT64 mem_mask);
+
+
+/* device read/write handlers */
+typedef UINT8 (*read8_device_func) (ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset);
+typedef void (*write8_device_func) (ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT8 data);
+typedef UINT16 (*read16_device_func) (ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 mem_mask);
+typedef void (*write16_device_func)(ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 data, ATTR_UNUSED UINT16 mem_mask);
+typedef UINT32 (*read32_device_func) (ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 mem_mask);
+typedef void (*write32_device_func)(ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 data, ATTR_UNUSED UINT32 mem_mask);
+typedef UINT64 (*read64_device_func) (ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 mem_mask);
+typedef void (*write64_device_func)(ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 data, ATTR_UNUSED UINT64 mem_mask);
+
+
+/* data_accessors is a struct with accessors of all flavors */
+typedef struct _data_accessors data_accessors;
+struct _data_accessors
+{
+ void (*change_pc)(offs_t byteaddress);
+
+ UINT8 (*read_byte)(offs_t byteaddress);
+ UINT16 (*read_word)(offs_t byteaddress);
+ UINT32 (*read_dword)(offs_t byteaddress);
+ UINT32 (*read_dword_masked)(offs_t byteaddress, UINT32 mask);
+ UINT64 (*read_qword)(offs_t byteaddress);
+ UINT64 (*read_qword_masked)(offs_t byteaddress, UINT64 mask);
+
+ void (*write_byte)(offs_t byteaddress, UINT8 data);
+ void (*write_word)(offs_t byteaddress, UINT16 data);
+ void (*write_dword)(offs_t byteaddress, UINT32 data);
+ void (*write_dword_masked)(offs_t byteaddress, UINT32 data, UINT32 mask);
+ void (*write_qword)(offs_t byteaddress, UINT64 data);
+ void (*write_qword_masked)(offs_t byteaddress, UINT64 data, UINT64 mask);
+};
+
+
+/* read_handler is a union of all the different read handler types */
+typedef union _read_handler read_handler;
+union _read_handler
{
- genf * handler;
- read8_machine_func mhandler8;
- read16_machine_func mhandler16;
- read32_machine_func mhandler32;
- read64_machine_func mhandler64;
- read8_device_func dhandler8;
- read16_device_func dhandler16;
- read32_device_func dhandler32;
- read64_device_func dhandler64;
+ genf * generic; /* generic function pointer */
+ read8_machine_func mhandler8; /* 8-bit machine read handler */
+ read16_machine_func mhandler16; /* 16-bit machine read handler */
+ read32_machine_func mhandler32; /* 32-bit machine read handler */
+ read64_machine_func mhandler64; /* 64-bit machine read handler */
+ read8_device_func dhandler8; /* 8-bit device read handler */
+ read16_device_func dhandler16; /* 16-bit device read handler */
+ read32_device_func dhandler32; /* 32-bit device read handler */
+ read64_device_func dhandler64; /* 64-bit device read handler */
};
-/* ----- a union of all the different write handler types ----- */
-typedef union _write_handlers write_handlers;
-union _write_handlers
+
+/* write_handler is a union of all the different write handler types */
+typedef union _write_handler write_handler;
+union _write_handler
{
- genf * handler;
- write8_machine_func mhandler8;
- write16_machine_func mhandler16;
- write32_machine_func mhandler32;
- write64_machine_func mhandler64;
- write8_device_func dhandler8;
- write16_device_func dhandler16;
- write32_device_func dhandler32;
- write64_device_func dhandler64;
+ genf * generic; /* generic function pointer */
+ write8_machine_func mhandler8; /* 8-bit machine write handler */
+ write16_machine_func mhandler16; /* 16-bit machine write handler */
+ write32_machine_func mhandler32; /* 32-bit machine write handler */
+ write64_machine_func mhandler64; /* 64-bit machine write handler */
+ write8_device_func dhandler8; /* 8-bit device write handler */
+ write16_device_func dhandler16; /* 16-bit device write handler */
+ write32_device_func dhandler32; /* 32-bit device write handler */
+ write64_device_func dhandler64; /* 64-bit device write handler */
};
-typedef union _memory_handlers memory_handlers;
-union _memory_handlers
+
+/* memory_handler is a union of all read and write handler types */
+typedef union _memory_handler memory_handler;
+union _memory_handler
{
- read_handlers read;
- write_handlers write;
+ genf * generic; /* generic function pointer */
+ read_handler read; /* read handler union */
+ write_handler write; /* write handler union */
};
-/* ----- a generic address map type ----- */
+
+/* address_map_entry is a linked list element describing one address range in a map */
typedef struct _address_map_entry address_map_entry;
struct _address_map_entry
{
- address_map_entry * next; /* pointer to the next entry */
-
- offs_t addrstart; /* start address */
- offs_t addrend; /* end address */
- offs_t addrmirror; /* mirror bits */
- offs_t addrmask; /* mask bits */
- read_handlers read; /* read handler callback */
- const char * read_name; /* read handler callback name */
- device_type read_devtype; /* read device type for device references */
- const char * read_devtag; /* read tag for the relevant device */
- write_handlers write; /* write handler callback */
- const char * write_name; /* write handler callback name */
- device_type write_devtype; /* read device type for device references */
- const char * write_devtag; /* read tag for the relevant device */
- UINT32 share; /* index of a shared memory block */
- void ** baseptr; /* receives pointer to memory (optional) */
- size_t * sizeptr; /* receives size of area in bytes (optional) */
- UINT32 baseptroffs_plus1; /* offset of base pointer within driver_data struct, plus 1 */
- UINT32 sizeptroffs_plus1; /* offset of size pointer within driver_data struct, plus 1 */
- UINT32 region; /* region containing the memory backing this entry */
- offs_t region_offs; /* offset within the region */
-
- void * memory; /* pointer to memory backing this entry */
- offs_t bytestart; /* byte-adjusted start address */
- offs_t byteend; /* byte-adjusted end address */
- offs_t bytemirror; /* byte-adjusted mirror bits */
- offs_t bytemask; /* byte-adjusted mask bits */
+ address_map_entry * next; /* pointer to the next entry */
+
+ offs_t addrstart; /* start address */
+ offs_t addrend; /* end address */
+ offs_t addrmirror; /* mirror bits */
+ offs_t addrmask; /* mask bits */
+ read_handler read; /* read handler callback */
+ const char * read_name; /* read handler callback name */
+ device_type read_devtype; /* read device type for device references */
+ const char * read_devtag; /* read tag for the relevant device */
+ write_handler write; /* write handler callback */
+ const char * write_name; /* write handler callback name */
+ device_type write_devtype; /* read device type for device references */
+ const char * write_devtag; /* read tag for the relevant device */
+ UINT32 share; /* index of a shared memory block */
+ void ** baseptr; /* receives pointer to memory (optional) */
+ size_t * sizeptr; /* receives size of area in bytes (optional) */
+ UINT32 baseptroffs_plus1; /* offset of base pointer within driver_data, plus 1 */
+ UINT32 sizeptroffs_plus1; /* offset of size pointer within driver_data, plus 1 */
+ UINT32 region; /* region containing the memory backing this entry */
+ offs_t region_offs; /* offset within the region */
+
+ void * memory; /* pointer to memory backing this entry */
+ offs_t bytestart; /* byte-adjusted start address */
+ offs_t byteend; /* byte-adjusted end address */
+ offs_t bytemirror; /* byte-adjusted mirror bits */
+ offs_t bytemask; /* byte-adjusted mask bits */
};
+
+/* address_map holds global map parameters plus the head of the list of entries */
typedef struct _address_map address_map;
struct _address_map
{
- UINT8 spacenum; /* space number of the map */
- UINT8 databits; /* data bits represented by the map */
- UINT8 unmapval; /* unmapped memory value */
- offs_t globalmask; /* global mask */
- address_map_entry * entrylist; /* list of entries */
+ UINT8 spacenum; /* space number of the map */
+ UINT8 databits; /* data bits represented by the map */
+ UINT8 unmapval; /* unmapped memory value */
+ offs_t globalmask; /* global mask */
+ address_map_entry * entrylist; /* list of entries */
};
-/* ----- structs to contain internal data ----- */
+
+/* address_space holds live information about an address space */
typedef struct _address_space address_space;
struct _address_space
{
- offs_t bytemask; /* byte-adjusted address mask */
- UINT8 * readlookup; /* read table lookup */
- UINT8 * writelookup; /* write table lookup */
- handler_data * readhandlers; /* read handlers */
- handler_data * writehandlers; /* write handlers */
- const data_accessors *accessors; /* pointers to the data access handlers */
+ offs_t bytemask; /* byte-adjusted address mask */
+ UINT8 * readlookup; /* read table lookup */
+ UINT8 * writelookup; /* write table lookup */
+ handler_data * readhandlers; /* read handlers */
+ handler_data * writehandlers; /* write handlers */
+ const data_accessors * accessors; /* pointers to the data access handlers */
};
+/* addrmap_token is a union of all types for a generic address map */
typedef union _addrmap_token addrmap_token;
union _addrmap_token
{
TOKEN_COMMON_FIELDS
const addrmap_token * tokenptr;
- read_handlers read; /* generic read handlers */
- write_handlers write; /* generic write handlers */
+ read_handler read; /* generic read handlers */
+ write_handler write; /* generic write handlers */
device_type devtype; /* device type */
UINT8 ** memptr; /* memory pointer */
size_t * sizeptr; /* size pointer */
};
+/* addrmap8_token is a union of all types for an 8-bit address map */
typedef union _addrmap8_token addrmap8_token;
union _addrmap8_token
{
@@ -325,14 +264,15 @@ union _addrmap8_token
write8_machine_func mwrite; /* pointer to native machine write handler */
read8_device_func dread; /* pointer to native device read handler */
write8_device_func dwrite; /* pointer to native device write handler */
- read_handlers read; /* generic read handlers */
- write_handlers write; /* generic write handlers */
+ read_handler read; /* generic read handlers */
+ write_handler write; /* generic write handlers */
device_type devtype; /* device type */
UINT8 ** memptr; /* memory pointer */
size_t * sizeptr; /* size pointer */
};
+/* addrmap16_token is a union of all types for a 16-bit address map */
typedef union _addrmap16_token addrmap16_token;
union _addrmap16_token
{
@@ -344,14 +284,15 @@ union _addrmap16_token
write16_device_func dwrite; /* pointer to native device write handler */
read8_machine_func mread8; /* pointer to 8-bit machine read handler */
write8_machine_func mwrite8; /* pointer to 8-bit machine write handler */
- read_handlers read; /* generic read handlers */
- write_handlers write; /* generic write handlers */
+ read_handler read; /* generic read handlers */
+ write_handler write; /* generic write handlers */
device_type devtype; /* device type */
UINT16 ** memptr; /* memory pointer */
size_t * sizeptr; /* size pointer */
};
+/* addrmap32_token is a union of all types for a 32-bit address map */
typedef union _addrmap32_token addrmap32_token;
union _addrmap32_token
{
@@ -365,14 +306,15 @@ union _addrmap32_token
write8_machine_func mwrite8; /* pointer to 8-bit machine write handler */
read16_machine_func mread16; /* pointer to 16-bit machine read handler */
write16_machine_func mwrite16; /* pointer to 16-bit machine write handler */
- read_handlers read; /* generic read handlers */
- write_handlers write; /* generic write handlers */
+ read_handler read; /* generic read handlers */
+ write_handler write; /* generic write handlers */
device_type devtype; /* device type */
UINT32 ** memptr; /* memory pointer */
size_t * sizeptr; /* size pointer */
};
+/* addrmap64_token is a union of all types for a 64-bit address map */
typedef union _addrmap64_token addrmap64_token;
union _addrmap64_token
{
@@ -388,46 +330,207 @@ union _addrmap64_token
write16_machine_func mwrite16; /* pointer to 16-bit machine write handler */
read32_machine_func mread32; /* pointer to 32-bit machine read handler */
write32_machine_func mwrite32; /* pointer to 32-bit machine write handler */
- read_handlers read; /* generic read handlers */
- write_handlers write; /* generic write handlers */
+ read_handler read; /* generic read handlers */
+ write_handler write; /* generic write handlers */
device_type devtype; /* device type */
UINT64 ** memptr; /* memory pointer */
size_t * sizeptr; /* size pointer */
};
+
/***************************************************************************
- ADDRESS MAP ARRAY CONSTRUCTORS
+ MACROS
***************************************************************************/
-#define address_map_0 NULL
+/* opcode base adjustment handler function macro */
+#define OPBASE_HANDLER(name) offs_t name(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t address)
-enum
-{
- ADDRMAP_TOKEN_INVALID,
- ADDRMAP_TOKEN_START,
- ADDRMAP_TOKEN_END,
- ADDRMAP_TOKEN_INCLUDE,
-
- ADDRMAP_TOKEN_GLOBAL_MASK,
- ADDRMAP_TOKEN_UNMAP_VALUE,
+/* machine read/write handler function macros */
+#define READ8_HANDLER(name) UINT8 name(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset)
+#define WRITE8_HANDLER(name) void name(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT8 data)
+#define READ16_HANDLER(name) UINT16 name(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 mem_mask)
+#define WRITE16_HANDLER(name) void name(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 data, ATTR_UNUSED UINT16 mem_mask)
+#define READ32_HANDLER(name) UINT32 name(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 mem_mask)
+#define WRITE32_HANDLER(name) void name(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 data, ATTR_UNUSED UINT32 mem_mask)
+#define READ64_HANDLER(name) UINT64 name(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 mem_mask)
+#define WRITE64_HANDLER(name) void name(ATTR_UNUSED running_machine *machine, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 data, ATTR_UNUSED UINT64 mem_mask)
- ADDRMAP_TOKEN_RANGE,
- ADDRMAP_TOKEN_MASK,
- ADDRMAP_TOKEN_MIRROR,
- ADDRMAP_TOKEN_READ,
- ADDRMAP_TOKEN_WRITE,
- ADDRMAP_TOKEN_DEVICE_READ,
- ADDRMAP_TOKEN_DEVICE_WRITE,
- ADDRMAP_TOKEN_READ_PORT,
- ADDRMAP_TOKEN_REGION,
- ADDRMAP_TOKEN_SHARE,
- ADDRMAP_TOKEN_BASEPTR,
- ADDRMAP_TOKEN_BASE_MEMBER,
- ADDRMAP_TOKEN_SIZEPTR,
- ADDRMAP_TOKEN_SIZE_MEMBER
-};
+
+/* device read/write handler function macros */
+#define READ8_DEVICE_HANDLER(name) UINT8 name(ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset)
+#define WRITE8_DEVICE_HANDLER(name) void name(ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT8 data)
+#define READ16_DEVICE_HANDLER(name) UINT16 name(ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 mem_mask)
+#define WRITE16_DEVICE_HANDLER(name) void name(ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 data, ATTR_UNUSED UINT16 mem_mask)
+#define READ32_DEVICE_HANDLER(name) UINT32 name(ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 mem_mask)
+#define WRITE32_DEVICE_HANDLER(name) void name(ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 data, ATTR_UNUSED UINT32 mem_mask)
+#define READ64_DEVICE_HANDLER(name) UINT64 name(ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 mem_mask)
+#define WRITE64_DEVICE_HANDLER(name) void name(ATTR_UNUSED device_config *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 data, ATTR_UNUSED UINT64 mem_mask)
+
+
+/* static memory handler (SMH) macros that can be used in place of read/write handlers */
+#define SMH_RAM ((void *)STATIC_RAM)
+#define SMH_ROM ((void *)STATIC_ROM)
+#define SMH_NOP ((void *)STATIC_NOP)
+#define SMH_UNMAP ((void *)STATIC_UNMAP)
+#define SMH_BANK(n) ((void *)(STATIC_BANK1 + (n) - 1))
+#define SMH_BANK1 SMH_BANK(1)
+#define SMH_BANK2 SMH_BANK(2)
+#define SMH_BANK3 SMH_BANK(3)
+#define SMH_BANK4 SMH_BANK(4)
+#define SMH_BANK5 SMH_BANK(5)
+#define SMH_BANK6 SMH_BANK(6)
+#define SMH_BANK7 SMH_BANK(7)
+#define SMH_BANK8 SMH_BANK(8)
+#define SMH_BANK9 SMH_BANK(9)
+#define SMH_BANK10 SMH_BANK(10)
+#define SMH_BANK11 SMH_BANK(11)
+#define SMH_BANK12 SMH_BANK(12)
+#define SMH_BANK13 SMH_BANK(13)
+#define SMH_BANK14 SMH_BANK(14)
+#define SMH_BANK15 SMH_BANK(15)
+#define SMH_BANK16 SMH_BANK(16)
+#define SMH_BANK17 SMH_BANK(17)
+#define SMH_BANK18 SMH_BANK(18)
+#define SMH_BANK19 SMH_BANK(19)
+#define SMH_BANK20 SMH_BANK(20)
+#define SMH_BANK21 SMH_BANK(21)
+#define SMH_BANK22 SMH_BANK(22)
+#define SMH_BANK23 SMH_BANK(23)
+#define SMH_BANK24 SMH_BANK(24)
+#define SMH_BANK25 SMH_BANK(25)
+#define SMH_BANK26 SMH_BANK(26)
+#define SMH_BANK27 SMH_BANK(27)
+#define SMH_BANK28 SMH_BANK(28)
+#define SMH_BANK29 SMH_BANK(29)
+#define SMH_BANK30 SMH_BANK(30)
+#define SMH_BANK31 SMH_BANK(31)
+#define SMH_BANK32 SMH_BANK(32)
+
+
+/* helper macro for merging data with the memory mask */
+#define COMBINE_DATA(varptr) (*(varptr) = (*(varptr) & mem_mask) | (data & ~mem_mask))
+
+
+/* 16-bit memory access tests */
+#define ACCESSING_LSB16 ((mem_mask & 0x00ff) == 0)
+#define ACCESSING_MSB16 ((mem_mask & 0xff00) == 0)
+#define ACCESSING_LSB ACCESSING_LSB16
+#define ACCESSING_MSB ACCESSING_MSB16
+
+
+/* 32-bit memory access tests */
+#define ACCESSING_LSW32 ((mem_mask & 0x0000ffff) == 0)
+#define ACCESSING_MSW32 ((mem_mask & 0xffff0000) == 0)
+#define ACCESSING_LSB32 ((mem_mask & 0x000000ff) == 0)
+#define ACCESSING_MSB32 ((mem_mask & 0xff000000) == 0)
+
+
+/* bank switching for CPU cores */
+#define change_pc(byteaddress) memory_set_opbase(byteaddress)
+
+
+/* forces the next branch to generate a call to the opbase handler */
+#define catch_nextBranch() do { opcode_entry = 0xff; } while (0)
+
+
+/* opcode range safety check */
+#define address_is_unsafe(A) ((UNEXPECTED((A) < opcode_memory_min) || UNEXPECTED((A) > opcode_memory_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])
+
+
+/* wrappers for dynamic read handler installation */
+#define memory_install_read_handler(cpu, space, start, end, mask, mirror, handler) \
+ _memory_install_read_handler(cpu, space, start, end, mask, mirror, handler, #handler)
+#define memory_install_read8_handler(cpu, space, start, end, mask, mirror, handler) \
+ _memory_install_read8_handler(cpu, space, start, end, mask, mirror, handler, #handler)
+#define memory_install_read16_handler(cpu, space, start, end, mask, mirror, handler) \
+ _memory_install_read16_handler(cpu, space, start, end, mask, mirror, handler, #handler)
+#define memory_install_read32_handler(cpu, space, start, end, mask, mirror, handler) \
+ _memory_install_read32_handler(cpu, space, start, end, mask, mirror, handler, #handler)
+#define memory_install_read64_handler(cpu, space, start, end, mask, mirror, handler) \
+ _memory_install_read64_handler(cpu, space, start, end, mask, mirror, handler, #handler)
+
+
+/* wrappers for dynamic write handler installation */
+#define memory_install_write_handler(cpu, space, start, end, mask, mirror, handler) \
+ _memory_install_write_handler(cpu, space, start, end, mask, mirror, handler, #handler)
+#define memory_install_write8_handler(cpu, space, start, end, mask, mirror, handler) \
+ _memory_install_write8_handler(cpu, space, start, end, mask, mirror, handler, #handler)
+#define memory_install_write16_handler(cpu, space, start, end, mask, mirror, handler) \
+ _memory_install_write16_handler(cpu, space, start, end, mask, mirror, handler, #handler)
+#define memory_install_write32_handler(cpu, space, start, end, mask, mirror, handler) \
+ _memory_install_write32_handler(cpu, space, start, end, mask, mirror, handler, #handler)
+#define memory_install_write64_handler(cpu, space, start, end, mask, mirror, handler) \
+ _memory_install_write64_handler(cpu, space, start, end, mask, mirror, handler, #handler)
+
+
+/* wrappers for dynamic read/write handler installation */
+#define memory_install_readwrite_handler(cpu, space, start, end, mask, mirror, rhandler, whandler) \
+ _memory_install_readwrite_handler(cpu, space, start, end, mask, mirror, rhandler, whandler, #rhandler, #whandler)
+#define memory_install_readwrite8_handler(cpu, space, start, end, mask, mirror, rhandler, whandler) \
+ _memory_install_readwrite8_handler(cpu, space, start, end, mask, mirror, rhandler, whandler, #rhandler, #whandler)
+#define memory_install_readwrite16_handler(cpu, space, start, end, mask, mirror, rhandler, whandler) \
+ _memory_install_readwrite16_handler(cpu, space, start, end, mask, mirror, rhandler, whandler, #rhandler, #whandler)
+#define memory_install_readwrite32_handler(cpu, space, start, end, mask, mirror, rhandler, whandler) \
+ _memory_install_readwrite32_handler(cpu, space, start, end, mask, mirror, rhandler, whandler, #rhandler, #whandler)
+#define memory_install_readwrite64_handler(cpu, space, start, end, mask, mirror, rhandler, whandler) \
+ _memory_install_readwrite64_handler(cpu, space, start, end, mask, mirror, rhandler, whandler, #rhandler, #whandler)
+
+
+/* macros for accessing bytes and words within larger chunks */
+#ifdef LSB_FIRST
+
+#define BYTE_XOR_BE(a) ((a) ^ 1) /* read/write a byte to a 16-bit space */
+#define BYTE_XOR_LE(a) (a)
+#define BYTE4_XOR_BE(a) ((a) ^ 3) /* read/write a byte to a 32-bit space */
+#define BYTE4_XOR_LE(a) (a)
+#define WORD_XOR_BE(a) ((a) ^ 2) /* read/write a word to a 32-bit space */
+#define WORD_XOR_LE(a) (a)
+#define BYTE8_XOR_BE(a) ((a) ^ 7) /* read/write a byte to a 64-bit space */
+#define BYTE8_XOR_LE(a) (a)
+#define WORD2_XOR_BE(a) ((a) ^ 6) /* read/write a word to a 64-bit space */
+#define WORD2_XOR_LE(a) (a)
+#define DWORD_XOR_BE(a) ((a) ^ 4) /* read/write a dword to a 64-bit space */
+#define DWORD_XOR_LE(a) (a)
+
+#else
+
+#define BYTE_XOR_BE(a) (a)
+#define BYTE_XOR_LE(a) ((a) ^ 1) /* read/write a byte to a 16-bit space */
+#define BYTE4_XOR_BE(a) (a)
+#define BYTE4_XOR_LE(a) ((a) ^ 3) /* read/write a byte to a 32-bit space */
+#define WORD_XOR_BE(a) (a)
+#define WORD_XOR_LE(a) ((a) ^ 2) /* read/write a word to a 32-bit space */
+#define BYTE8_XOR_BE(a) (a)
+#define BYTE8_XOR_LE(a) ((a) ^ 7) /* read/write a byte to a 64-bit space */
+#define WORD2_XOR_BE(a) (a)
+#define WORD2_XOR_LE(a) ((a) ^ 6) /* read/write a word to a 64-bit space */
+#define DWORD_XOR_BE(a) (a)
+#define DWORD_XOR_LE(a) ((a) ^ 4) /* read/write a dword to a 64-bit space */
+
+#endif
+
+
+
+/***************************************************************************
+ ADDRESS MAP MACROS
+***************************************************************************/
+
+/* so that "0" can be used for unneeded address maps */
+#define address_map_0 NULL
/* start/end tags for the address map */
@@ -519,7 +622,8 @@ enum
#define AM_SIZE_MEMBER(_struct, _member) \
TOKEN_UINT32_PACK2(ADDRMAP_TOKEN_SIZE_MEMBER, 8, offsetof(_struct, _member), 24),
-/* ----- common shortcuts ----- */
+
+/* common shortcuts */
#define AM_READWRITE(_read,_write) AM_READ(_read) AM_WRITE(_write)
#define AM_DEVREADWRITE(_type,_tag,_read,_write) AM_DEVREAD(_type,_tag,_read) AM_DEVWRITE(_type,_tag,_write)
#define AM_ROM AM_READ(SMH_ROM)
@@ -535,23 +639,10 @@ enum
/***************************************************************************
- ADDRESS MAP LOOKUP CONSTANTS
-***************************************************************************/
-
-/* ----- address spaces ----- */
-enum
-{
- ADDRESS_SPACE_PROGRAM = 0, /* program address space */
- ADDRESS_SPACE_DATA, /* data address space */
- ADDRESS_SPACE_IO, /* I/O address space */
- ADDRESS_SPACES /* maximum number of address spaces */
-};
-
-/***************************************************************************
FUNCTION PROTOTYPES FOR CORE READ/WRITE ROUTINES
***************************************************************************/
-/* ----- declare program address space handlers ----- */
+/* declare program address space handlers */
UINT8 program_read_byte_8(offs_t address);
void program_write_byte_8(offs_t address, UINT8 data);
@@ -605,7 +696,7 @@ void program_write_dword_64le(offs_t address, UINT32 data);
void program_write_qword_64le(offs_t address, UINT64 data);
void program_write_masked_64le(offs_t address, UINT64 data, UINT64 mem_mask);
-/* ----- declare data address space handlers ----- */
+/* declare data address space handlers */
UINT8 data_read_byte_8(offs_t address);
void data_write_byte_8(offs_t address, UINT8 data);
@@ -659,7 +750,7 @@ void data_write_dword_64le(offs_t address, UINT32 data);
void data_write_qword_64le(offs_t address, UINT64 data);
void data_write_masked_64le(offs_t address, UINT64 data, UINT64 mem_mask);
-/* ----- declare I/O address space handlers ----- */
+/* declare I/O address space handlers */
UINT8 io_read_byte_8(offs_t address);
void io_write_byte_8(offs_t address, UINT8 data);
@@ -719,28 +810,37 @@ void io_write_masked_64le(offs_t address, UINT64 data, UINT64 mem_mask);
FUNCTION PROTOTYPES FOR CORE MEMORY FUNCTIONS
***************************************************************************/
-/* ----- memory setup function ----- */
+/* memory setup function */
void memory_init(running_machine *machine);
void memory_set_context(int activecpu);
-/* ----- address map functions ----- */
+
+
+/* ----- address maps ----- */
+
+/* build and allocate an address map for a CPU's address space */
address_map *address_map_alloc(const machine_config *drv, int cpunum, int spacenum);
-void address_map_free(address_map *map);
-const address_map *memory_get_map(int cpunum, int spacenum);
-/* ----- opcode base control ---- */
+/* release allocated memory for an address map */
+void address_map_free(address_map *map);
+
+/* return a pointer to the constructed address map for a CPU's address space */
+const address_map *memory_get_address_map(int cpunum, int spacenum);
+
+
+/* opcode base control */
opbase_handler_func memory_set_opbase_handler(int cpunum, opbase_handler_func function);
void memory_set_opbase(offs_t byteaddress);
-/* ----- separate opcode/data encryption helper ---- */
+/* separate opcode/data encryption helper */
void memory_set_decrypted_region(int cpunum, offs_t bytestart, offs_t byteend, void *base);
-/* ----- return a base pointer to memory ---- */
+/* return a base pointer to memory */
void * memory_get_read_ptr(int cpunum, int spacenum, offs_t byteaddress);
void * memory_get_write_ptr(int cpunum, int spacenum, offs_t byteaddress);
void * memory_get_op_ptr(int cpunum, offs_t byteaddress, int arg);
-/* ----- memory banking ----- */
+/* memory banking */
void memory_configure_bank(int banknum, int startentry, int numentries, void *base, offs_t stride);
void memory_configure_bank_decrypted(int banknum, int startentry, int numentries, void *base, offs_t stride);
void memory_set_bank(int banknum, int entrynum);
@@ -749,12 +849,12 @@ void memory_set_bankptr(int banknum, void *base);
const data_accessors *memory_get_accessors(int spacenum, int databits, int endianness);
-/* ----- debugging ----- */
+/* debugging */
void memory_set_debugger_access(int debugger);
void memory_set_log_unmap(int spacenum, int log);
int memory_get_log_unmap(int spacenum);
-/* ----- dynamic address space mapping ----- */
+/* dynamic address space mapping */
void * _memory_install_read_handler (int cpunum, int spacenum, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, FPTR handler, const char *handler_name);
UINT8 * _memory_install_read8_handler (int cpunum, int spacenum, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read8_machine_func handler, const char *handler_name);
UINT16 * _memory_install_read16_handler (int cpunum, int spacenum, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read16_machine_func handler, const char *handler_name);
@@ -771,7 +871,7 @@ UINT16 * _memory_install_readwrite16_handler(int cpunum, int spacenum, offs_t ad
UINT32 * _memory_install_readwrite32_handler(int cpunum, int spacenum, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read32_machine_func rhandler, write32_machine_func whandler, const char *rhandler_name, const char *whandler_name);
UINT64 * _memory_install_readwrite64_handler(int cpunum, int spacenum, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read64_machine_func rhandler, write64_machine_func whandler, const char *rhandler_name, const char *whandler_name);
-/* ----- memory debugging ----- */
+/* memory debugging */
void memory_dump(FILE *file);
const char *memory_get_handler_string(int read0_or_write1, int cpunum, int spacenum, offs_t byteaddress);
@@ -796,59 +896,7 @@ extern const char *const address_space_names[ADDRESS_SPACES];
HELPER MACROS AND INLINES
***************************************************************************/
-/* ----- 16/32-bit memory accessing ----- */
-#define COMBINE_DATA(varptr) (*(varptr) = (*(varptr) & mem_mask) | (data & ~mem_mask))
-
-/* ----- 16-bit memory accessing ----- */
-#define ACCESSING_LSB16 ((mem_mask & 0x00ff) == 0)
-#define ACCESSING_MSB16 ((mem_mask & 0xff00) == 0)
-#define ACCESSING_LSB ACCESSING_LSB16
-#define ACCESSING_MSB ACCESSING_MSB16
-
-/* ----- 32-bit memory accessing ----- */
-#define ACCESSING_LSW32 ((mem_mask & 0x0000ffff) == 0)
-#define ACCESSING_MSW32 ((mem_mask & 0xffff0000) == 0)
-#define ACCESSING_LSB32 ((mem_mask & 0x000000ff) == 0)
-#define ACCESSING_MSB32 ((mem_mask & 0xff000000) == 0)
-
-/* ----- opcode range safety checks ----- */
-#define address_is_unsafe(A) ((UNEXPECTED((A) < opcode_memory_min) || UNEXPECTED((A) > opcode_memory_max)))
-
-/* ----- dynamic memory installation ----- */
-#define memory_install_read_handler(cpu, space, start, end, mask, mirror, handler) \
- _memory_install_read_handler(cpu, space, start, end, mask, mirror, handler, #handler)
-#define memory_install_read8_handler(cpu, space, start, end, mask, mirror, handler) \
- _memory_install_read8_handler(cpu, space, start, end, mask, mirror, handler, #handler)
-#define memory_install_read16_handler(cpu, space, start, end, mask, mirror, handler) \
- _memory_install_read16_handler(cpu, space, start, end, mask, mirror, handler, #handler)
-#define memory_install_read32_handler(cpu, space, start, end, mask, mirror, handler) \
- _memory_install_read32_handler(cpu, space, start, end, mask, mirror, handler, #handler)
-#define memory_install_read64_handler(cpu, space, start, end, mask, mirror, handler) \
- _memory_install_read64_handler(cpu, space, start, end, mask, mirror, handler, #handler)
-
-#define memory_install_write_handler(cpu, space, start, end, mask, mirror, handler) \
- _memory_install_write_handler(cpu, space, start, end, mask, mirror, handler, #handler)
-#define memory_install_write8_handler(cpu, space, start, end, mask, mirror, handler) \
- _memory_install_write8_handler(cpu, space, start, end, mask, mirror, handler, #handler)
-#define memory_install_write16_handler(cpu, space, start, end, mask, mirror, handler) \
- _memory_install_write16_handler(cpu, space, start, end, mask, mirror, handler, #handler)
-#define memory_install_write32_handler(cpu, space, start, end, mask, mirror, handler) \
- _memory_install_write32_handler(cpu, space, start, end, mask, mirror, handler, #handler)
-#define memory_install_write64_handler(cpu, space, start, end, mask, mirror, handler) \
- _memory_install_write64_handler(cpu, space, start, end, mask, mirror, handler, #handler)
-
-#define memory_install_readwrite_handler(cpu, space, start, end, mask, mirror, rhandler, whandler) \
- _memory_install_readwrite_handler(cpu, space, start, end, mask, mirror, rhandler, whandler, #rhandler, #whandler)
-#define memory_install_readwrite8_handler(cpu, space, start, end, mask, mirror, rhandler, whandler) \
- _memory_install_readwrite8_handler(cpu, space, start, end, mask, mirror, rhandler, whandler, #rhandler, #whandler)
-#define memory_install_readwrite16_handler(cpu, space, start, end, mask, mirror, rhandler, whandler) \
- _memory_install_readwrite16_handler(cpu, space, start, end, mask, mirror, rhandler, whandler, #rhandler, #whandler)
-#define memory_install_readwrite32_handler(cpu, space, start, end, mask, mirror, rhandler, whandler) \
- _memory_install_readwrite32_handler(cpu, space, start, end, mask, mirror, rhandler, whandler, #rhandler, #whandler)
-#define memory_install_readwrite64_handler(cpu, space, start, end, mask, mirror, rhandler, whandler) \
- _memory_install_readwrite64_handler(cpu, space, start, end, mask, mirror, rhandler, whandler, #rhandler, #whandler)
-
-/* ----- generic memory access ----- */
+/* generic memory access */
INLINE UINT8 program_read_byte (offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_PROGRAM].accessors->read_byte)(byteaddress); }
INLINE UINT16 program_read_word (offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_PROGRAM].accessors->read_word)(byteaddress); }
INLINE UINT32 program_read_dword(offs_t byteaddress) { return (*active_address_space[ADDRESS_SPACE_PROGRAM].accessors->read_dword)(byteaddress); }
@@ -879,7 +927,7 @@ INLINE void io_write_word (offs_t byteaddress, UINT16 data) { (*active_address_s
INLINE void io_write_dword(offs_t byteaddress, UINT32 data) { (*active_address_space[ADDRESS_SPACE_IO].accessors->write_dword)(byteaddress, data); }
INLINE void io_write_qword(offs_t byteaddress, UINT64 data) { (*active_address_space[ADDRESS_SPACE_IO].accessors->write_qword)(byteaddress, data); }
-/* ----- safe opcode and opcode argument reading ----- */
+/* safe opcode and opcode argument reading */
UINT8 cpu_readop_safe(offs_t byteaddress);
UINT16 cpu_readop16_safe(offs_t byteaddress);
UINT32 cpu_readop32_safe(offs_t byteaddress);
@@ -889,18 +937,7 @@ UINT16 cpu_readop_arg16_safe(offs_t byteaddress);
UINT32 cpu_readop_arg32_safe(offs_t byteaddress);
UINT64 cpu_readop_arg64_safe(offs_t byteaddress);
-/* ----- 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])
-
-/* ----- opcode and opcode argument reading ----- */
+/* 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); }
@@ -911,11 +948,5 @@ INLINE UINT16 cpu_readop_arg16(offs_t byteaddress) { if (address_is_unsafe(bytea
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); }
-/* ----- bank switching for CPU cores ----- */
-#define change_pc(byteaddress) do { memory_set_opbase(byteaddress); } while (0)
-
-/* ----- forces the next branch to generate a call to the opbase handler ----- */
-#define catch_nextBranch() do { opcode_entry = 0xff; } while (0)
-
#endif /* __MEMORY_H__ */
diff --git a/src/emu/validity.c b/src/emu/validity.c
index 7576e507fe9..660798f3cc8 100644
--- a/src/emu/validity.c
+++ b/src/emu/validity.c
@@ -700,7 +700,7 @@ static int validate_cpu(int drivnum, const machine_config *config, const UINT32
}
/* if this is a program space, auto-assign implicit ROM entries */
- if ((FPTR)entry->read.handler == STATIC_ROM && !entry->region)
+ if ((FPTR)entry->read.generic == STATIC_ROM && !entry->region)
{
entry->region = REGION_CPU1 + cpunum;
entry->region_offs = entry->addrstart;
diff --git a/src/mame/video/taitoic.c b/src/mame/video/taitoic.c
index 7c34f9fc296..ce377f24ba3 100644
--- a/src/mame/video/taitoic.c
+++ b/src/mame/video/taitoic.c
@@ -580,7 +580,7 @@ INLINE void taitoic_drawscanline(
static int has_write_handler(int cpunum, write16_machine_func handler)
{
- const address_map *map = memory_get_map(cpunum, ADDRESS_SPACE_PROGRAM);
+ const address_map *map = memory_get_address_map(cpunum, ADDRESS_SPACE_PROGRAM);
const address_map_entry *entry;
for (entry = map->entrylist; entry != NULL; entry = entry->next)
if (entry->write.mhandler16 == handler)