diff options
author | 2009-07-08 14:47:35 +0000 | |
---|---|---|
committer | 2009-07-08 14:47:35 +0000 | |
commit | 7b28233e47541c9c5bf075ff0e4af86f973a1917 (patch) | |
tree | 94ba6e9b6e3cf058b888026fbc254d4874c23f71 | |
parent | 54ca1938bc3e06bb473329c26d7db15474a79b17 (diff) |
Move address_map array from cpu_config to device_config. Added
MDRV macros in the device for specifying address maps. Changed
the memory system to fetch the maps from the new location.
This is just a small step toward the end goal of getting address
maps into arbitrary devices.
-rw-r--r-- | src/emu/cpuexec.h | 13 | ||||
-rw-r--r-- | src/emu/devintrf.c | 1 | ||||
-rw-r--r-- | src/emu/devintrf.h | 3 | ||||
-rw-r--r-- | src/emu/mamecore.h | 1 | ||||
-rw-r--r-- | src/emu/mconfig.c | 7 | ||||
-rw-r--r-- | src/emu/mconfig.h | 15 | ||||
-rw-r--r-- | src/emu/memory.c | 5 | ||||
-rw-r--r-- | src/emu/memory.h | 3 |
8 files changed, 36 insertions, 12 deletions
diff --git a/src/emu/cpuexec.h b/src/emu/cpuexec.h index 695f8bfbc53..79fdb59ca89 100644 --- a/src/emu/cpuexec.h +++ b/src/emu/cpuexec.h @@ -63,7 +63,6 @@ struct _cpu_config { cpu_type type; /* index for the CPU type */ UINT32 flags; /* flags; see #defines below */ - const addrmap_token *address_map[ADDRESS_SPACES]; /* 1 memory map per address space */ cpu_interrupt_func vblank_interrupt; /* for interrupts tied to VBLANK */ int vblank_interrupts_per_frame;/* usually 1 */ const char * vblank_interrupt_screen; /* the screen that causes the VBLANK interrupt */ @@ -111,14 +110,14 @@ struct _cpu_class_header #define MDRV_CPU_CONFIG(_config) \ MDRV_DEVICE_CONFIG(_config) -#define MDRV_CPU_PROGRAM_MAP(_map1) \ - MDRV_DEVICE_CONFIG_DATAPTR_ARRAY(cpu_config, address_map, ADDRESS_SPACE_PROGRAM, ADDRESS_MAP_NAME(_map1)) \ +#define MDRV_CPU_PROGRAM_MAP(_map) \ + MDRV_DEVICE_PROGRAM_MAP(_map) -#define MDRV_CPU_DATA_MAP(_map1) \ - MDRV_DEVICE_CONFIG_DATAPTR_ARRAY(cpu_config, address_map, ADDRESS_SPACE_DATA, ADDRESS_MAP_NAME(_map1)) \ +#define MDRV_CPU_DATA_MAP(_map) \ + MDRV_DEVICE_DATA_MAP(_map) -#define MDRV_CPU_IO_MAP(_map1) \ - MDRV_DEVICE_CONFIG_DATAPTR_ARRAY(cpu_config, address_map, ADDRESS_SPACE_IO, ADDRESS_MAP_NAME(_map1)) \ +#define MDRV_CPU_IO_MAP(_map) \ + MDRV_DEVICE_IO_MAP(_map) #define MDRV_CPU_VBLANK_INT(_tag, _func) \ MDRV_DEVICE_CONFIG_DATAPTR(cpu_config, vblank_interrupt, _func) \ diff --git a/src/emu/devintrf.c b/src/emu/devintrf.c index c04d5ee71f9..93f65677d0b 100644 --- a/src/emu/devintrf.c +++ b/src/emu/devintrf.c @@ -126,6 +126,7 @@ device_config *device_list_add(device_config **listheadptr, const device_config /* populate device configuration */ device->clock = clock; + memset(device->address_map, 0, sizeof(device->address_map)); if ((device->clock & 0xff000000) == 0xff000000) { assert(device->owner != NULL); diff --git a/src/emu/devintrf.h b/src/emu/devintrf.h index cc1a38febc5..38959bf402a 100644 --- a/src/emu/devintrf.h +++ b/src/emu/devintrf.h @@ -16,6 +16,7 @@ #include "mamecore.h" #include "romload.h" +#include "memory.h" /*************************************************************************** @@ -188,7 +189,6 @@ enum /* forward-declare these types */ typedef union _deviceinfo deviceinfo; -typedef struct _device_config device_config; /* a device contract */ @@ -252,6 +252,7 @@ struct _device_config /* device configuration (always valid) */ UINT32 clock; /* device clock */ + const addrmap_token * address_map[ADDRESS_SPACES]; /* address maps for each address space */ const void * static_config; /* static device configuration */ void * inline_config; /* inline device configuration */ diff --git a/src/emu/mamecore.h b/src/emu/mamecore.h index 1473ee7ee8c..dbe60cbc3a3 100644 --- a/src/emu/mamecore.h +++ b/src/emu/mamecore.h @@ -64,6 +64,7 @@ typedef struct _game_driver game_driver; typedef struct _machine_config machine_config; typedef struct _gfx_element gfx_element; typedef struct _mame_file mame_file; +typedef struct _device_config device_config; /* pen_t is used to represent pixel values in bitmaps */ diff --git a/src/emu/mconfig.c b/src/emu/mconfig.c index a4fe4e41031..2d1149b8585 100644 --- a/src/emu/mconfig.c +++ b/src/emu/mconfig.c @@ -155,6 +155,13 @@ static void machine_config_detokenize(machine_config *config, const machine_conf TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, device->clock, 32); break; + case MCONFIG_TOKEN_DEVICE_MAP: + assert(device != NULL); + TOKEN_UNGET_UINT32(tokens); + TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, data32, 8); + device->address_map[data32] = TOKEN_GET_PTR(tokens, addrmap); + break; + case MCONFIG_TOKEN_DEVICE_CONFIG: assert(device != NULL); device->static_config = TOKEN_GET_PTR(tokens, voidptr); diff --git a/src/emu/mconfig.h b/src/emu/mconfig.h index 6a2cadac025..fef4387004e 100644 --- a/src/emu/mconfig.h +++ b/src/emu/mconfig.h @@ -39,6 +39,7 @@ enum MCONFIG_TOKEN_DEVICE_REMOVE, MCONFIG_TOKEN_DEVICE_MODIFY, MCONFIG_TOKEN_DEVICE_CLOCK, + MCONFIG_TOKEN_DEVICE_MAP, MCONFIG_TOKEN_DEVICE_CONFIG, MCONFIG_TOKEN_DEVICE_CONFIG_DATA32, MCONFIG_TOKEN_DEVICE_CONFIG_DATA64, @@ -312,6 +313,20 @@ union _machine_config_token #define MDRV_DEVICE_CLOCK(_clock) \ TOKEN_UINT64_PACK2(MCONFIG_TOKEN_DEVICE_CLOCK, 8, _clock, 32), +#define MDRV_DEVICE_ADDRESS_MAP(_space, _map) \ + TOKEN_UINT32_PACK2(MCONFIG_TOKEN_DEVICE_MAP, 8, _space, 8), \ + TOKEN_PTR(addrmap, (const addrmap_token *)ADDRESS_MAP_NAME(_map)), + +#define MDRV_DEVICE_PROGRAM_MAP(_map) \ + MDRV_DEVICE_ADDRESS_MAP(ADDRESS_SPACE_PROGRAM, _map) + +#define MDRV_DEVICE_DATA_MAP(_map) \ + MDRV_DEVICE_ADDRESS_MAP(ADDRESS_SPACE_DATA, _map) + +#define MDRV_DEVICE_IO_MAP(_map) \ + MDRV_DEVICE_ADDRESS_MAP(ADDRESS_SPACE_IO, _map) + + /* inline device configurations that require 32 bits of storage in the token */ #define MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(_size, _offset, _val) \ diff --git a/src/emu/memory.c b/src/emu/memory.c index a531b0d214a..3da0caba3f1 100644 --- a/src/emu/memory.c +++ b/src/emu/memory.c @@ -764,7 +764,6 @@ const address_space *memory_find_address_space(const device_config *cpu, int spa address_map *address_map_alloc(const device_config *device, const game_driver *driver, int spacenum) { - const cpu_config *cpuconfig = (const cpu_config *)device->inline_config; const addrmap_token *internal_map; address_map *map; @@ -776,8 +775,8 @@ address_map *address_map_alloc(const device_config *device, const game_driver *d map_detokenize(map, driver, device->tag, internal_map); /* construct the standard map */ - if (cpuconfig->address_map[spacenum] != NULL) - map_detokenize(map, driver, device->tag, cpuconfig->address_map[spacenum]); + if (device->address_map[spacenum] != NULL) + map_detokenize(map, driver, device->tag, device->address_map[spacenum]); return map; } diff --git a/src/emu/memory.h b/src/emu/memory.h index f633b0d33b0..098be1cf20f 100644 --- a/src/emu/memory.h +++ b/src/emu/memory.h @@ -15,8 +15,9 @@ #define __MEMORY_H__ #include "mamecore.h" -#include "devintrf.h" #include "tokenize.h" +#include "astring.h" + /*************************************************************************** |