diff options
author | 2008-07-28 09:35:36 +0000 | |
---|---|---|
committer | 2008-07-28 09:35:36 +0000 | |
commit | 27fed1ec97c24877a1b44e114d7b9776cb776e8c (patch) | |
tree | 93eb6d00131b30c475d9d60b51f1f97c09e3b98d /src/emu | |
parent | 1b8118822915833267718cf56b24e5218b676ca4 (diff) |
Changed the way memory regions are referenced. Instead of a single
integer value, regions are now referred to by a region class and
a region tag. The class specifies the type of region (one of CPU,
gfx, sound, user, disk, prom, pld) while the tag uniquely specifies
the region. This change required updating all the ROM region
definitions in the project to specify the class/tag instead of
region number.
Updated the core memory_region_* functions to accept a class/tag
pair. Added new memory_region_next() function to allow for iteration
over all memory regions of a given class. Added new function
memory_region_class_name() to return the name for a given CPU
memory region class.
Changed the auto-binding behavior of CPU regions. Previously, the
first CPU would auto-bind to REGION_CPU1 (that is, any ROM references
would automatically assume that they lived in the corresponding
region). Now, each CPU automatically binds to the RGNCLASS_CPU region
with the same tag as the CPU itself. This behavior required ensuring
that all previous REGION_CPU* regions were changed to RGNCLASS_CPU
with the same tag as the CPU.
Introduced a new auto-binding mechanism for sound cores. This works
similarly to the CPU binding. Each sound core that requires a memory
region now auto-binds to the RGNCLASS_SOUND with the same tag as the
sound core. In almost all cases, this allowed for the removal of the
explicit region item in the sound configuration, which in turn
allowed for many sound configurations to removed altogether.
Updated the expression engine's memory reference behavior. A recent
update expanded the scope of memory references to allow for referencing
data in non-active CPU spaces, in memory regions, and in EEPROMs.
However, this previous update required an index, which is no longer
appropriate for regions and will become increasingly less appropriate
for CPUs over time. Instead, a new syntax is supported, of the form:
"[tag.][space]size@addr", where 'tag' is an optional tag for the CPU
or memory region you wish to access, followed by a period as a
separator; 'space' is the memory address space or region class you
wish to access (p/d/i for program/data/I/O spaces; o for opcode space;
r for direct RAM; c/u/g/s for CPU/user/gfx/sound regions; e for
EEPROMs); and 'size' is the usual b/w/d/q for byte/word/dword/qword.
Cleaned up ROM definition flags and removed some ugly hacks that had
existed previously. Expanded to support up to 256 BIOSes. Updated
ROM_COPY to support specifying class/tag for the source region.
Updated the address map AM_REGION macro to support specifying a
class/tag for the region.
Updated debugger windows to display the CPU and region tags where
appropriate.
Updated -listxml to output region class and tag for each ROM entry.
Diffstat (limited to 'src/emu')
136 files changed, 1050 insertions, 1094 deletions
diff --git a/src/emu/cheat.c b/src/emu/cheat.c index 1609ea319fb..8a15a6889c6 100644 --- a/src/emu/cheat.c +++ b/src/emu/cheat.c @@ -13376,7 +13376,7 @@ static void build_cpu_region_info_list(running_machine *machine) UINT8 region_type = ROMREGION_GETTYPE(traverse); /* non-cpu region */ - if(region_type >= REGION_GFX1 && region_type <= REGION_PLDS) + if(region_type >= RGNCLASS_GFX, "gfx1" && region_type <= REGION_PLDS) { UINT8 bit_state = 0; UINT32 length = memory_region_length(machine, region_type); diff --git a/src/emu/cpu/mb86233/mb86233.c b/src/emu/cpu/mb86233/mb86233.c index f87b78719bd..993e57cb987 100644 --- a/src/emu/cpu/mb86233/mb86233.c +++ b/src/emu/cpu/mb86233/mb86233.c @@ -133,7 +133,7 @@ static void mb86233_init(int index, int clock, const void *config, int (*irqcall memset( mb86233.RAM, 0, 2 * 0x200 * sizeof(UINT32) ); mb86233.ARAM = &mb86233.RAM[0]; mb86233.BRAM = &mb86233.RAM[0x200]; - mb86233.Tables = (UINT32*) memory_region(Machine, _config->Tables); + mb86233.Tables = (UINT32*) memory_region(Machine, RGNCLASS_USER, _config->tablergn); state_save_register_global_pointer(mb86233.RAM,2 * 0x200 * sizeof(UINT32)); } diff --git a/src/emu/cpu/mb86233/mb86233.h b/src/emu/cpu/mb86233/mb86233.h index 07311ea061f..9201f0954e0 100644 --- a/src/emu/cpu/mb86233/mb86233.h +++ b/src/emu/cpu/mb86233/mb86233.h @@ -45,7 +45,7 @@ struct mb86233_config { int (*fifo_read_cb)( UINT32* data ); void (*fifo_write_cb)( UINT32 data ); - int Tables; + const char *tablergn; }; extern void mb86233_get_info(UINT32 state, cpuinfo *info); diff --git a/src/emu/debug/debugcpu.c b/src/emu/debug/debugcpu.c index 20733e88ed6..96788efe303 100644 --- a/src/emu/debug/debugcpu.c +++ b/src/emu/debug/debugcpu.c @@ -98,15 +98,15 @@ static void watchpoint_check(int cpunum, int spacenum, int type, offs_t address, static void check_hotspots(int cpunum, int spacenum, offs_t address); /* expression handlers */ -static UINT64 expression_read_memory(int space, int index, UINT32 address, int size); +static UINT64 expression_read_memory(const char *name, int space, UINT32 address, int size); static UINT64 expression_read_address_space(int cpuindex, int space, offs_t address, int size); static UINT64 expression_read_program_direct(int cpuindex, int opcode, offs_t address, int size); -static UINT64 expression_read_memory_region(int rgnindex, int rgntype, offs_t address, int size); +static UINT64 expression_read_memory_region(int rgnclass, const char *rgntag, offs_t address, int size); static UINT64 expression_read_eeprom(offs_t address, int size); -static void expression_write_memory(int space, int index, UINT32 address, int size, UINT64 data); +static void expression_write_memory(const char *name, int space, UINT32 address, int size, UINT64 data); static void expression_write_address_space(int cpuindex, int space, offs_t address, int size, UINT64 data); static void expression_write_program_direct(int cpuindex, int opcode, offs_t address, int size, UINT64 data); -static void expression_write_memory_region(int rgnindex, int rgntype, offs_t address, int size, UINT64 data); +static void expression_write_memory_region(int rgnclass, const char *rgntag, offs_t address, int size, UINT64 data); static void expression_write_eeprom(offs_t address, int size, UINT64 data); /* variable getters/setters */ @@ -2137,7 +2137,7 @@ UINT64 debug_read_opcode(offs_t address, int size, int arg) space -------------------------------------------------*/ -static UINT64 expression_read_memory(int space, int index, UINT32 address, int size) +static UINT64 expression_read_memory(const char *name, int space, UINT32 address, int size) { int cpuindex; @@ -2146,26 +2146,42 @@ static UINT64 expression_read_memory(int space, int index, UINT32 address, int s case EXPSPACE_PROGRAM: case EXPSPACE_DATA: case EXPSPACE_IO: - cpuindex = (index == -1) ? cpu_getactivecpu() : index; - space = ADDRESS_SPACE_PROGRAM + (space - EXPSPACE_PROGRAM); - return expression_read_address_space(cpuindex, space, address, size); + cpuindex = (name != NULL) ? mame_find_cpu_index(Machine, name) : cpu_getactivecpu(); + if (cpuindex < 0) + break; + return expression_read_address_space(cpuindex, ADDRESS_SPACE_PROGRAM + (space - EXPSPACE_PROGRAM), address, size); case EXPSPACE_OPCODE: case EXPSPACE_RAMWRITE: - cpuindex = (index == -1) ? cpu_getactivecpu() : index; + cpuindex = (name != NULL) ? mame_find_cpu_index(Machine, name) : cpu_getactivecpu(); + if (cpuindex < 0) + break; + if (name == NULL) + name = Machine->config->cpu[cpu_getactivecpu()].tag; return expression_read_program_direct(cpuindex, (space == EXPSPACE_OPCODE), address, size); case EXPSPACE_EEPROM: return expression_read_eeprom(address, size); case EXPSPACE_CPU: + if (name == NULL) + break; + return expression_read_memory_region(RGNCLASS_CPU, name, address, size); + case EXPSPACE_USER: + if (name == NULL) + break; + return expression_read_memory_region(RGNCLASS_USER, name, address, size); + case EXPSPACE_GFX: + if (name == NULL) + break; + return expression_read_memory_region(RGNCLASS_GFX, name, address, size); + case EXPSPACE_SOUND: - if (index < 1) + if (name == NULL) break; - space = ADDRESS_SPACE_PROGRAM + (space - EXPSPACE_PROGRAM); - return expression_read_memory_region(index, space, address, size); + return expression_read_memory_region(RGNCLASS_SOUND, name, address, size); } return ~(UINT64)0 >> (64 - 8*size); } @@ -2268,61 +2284,46 @@ static UINT64 expression_read_program_direct(int cpuindex, int opcode, offs_t ad from a memory region -------------------------------------------------*/ -static UINT64 expression_read_memory_region(int rgnindex, int rgntype, offs_t address, int size) +static UINT64 expression_read_memory_region(int rgnclass, const char *rgntag, offs_t address, int size) { + UINT8 *base = memory_region(Machine, rgnclass, rgntag); UINT64 result = ~(UINT64)0 >> (64 - 8*size); - int rgnnum = -1; - - /* convert to a region number */ - switch (rgntype) - { - case EXPSPACE_CPU: rgnnum = REGION_CPU1 + (rgnindex - 1); break; - case EXPSPACE_USER: rgnnum = REGION_USER1 + (rgnindex - 1); break; - case EXPSPACE_GFX: rgnnum = REGION_GFX1 + (rgnindex - 1); break; - case EXPSPACE_SOUND: rgnnum = REGION_SOUND1 + (rgnindex - 1); break; - } - /* process if it exists */ - if (rgnnum != -1) + /* make sure we get a valid base before proceeding */ + if (base != NULL) { - UINT8 *base = memory_region(Machine, rgnnum); + UINT32 length = memory_region_length(Machine, rgnclass, rgntag); + UINT32 flags = memory_region_flags(Machine, rgnclass, rgntag); - /* make sure we get a valid base before proceeding */ - if (base != NULL) + /* call ourself recursively until we are byte-sized */ + if (size > 1) { - UINT32 length = memory_region_length(Machine, rgnnum); - UINT32 flags = memory_region_flags(Machine, rgnnum); - - /* call ourself recursively until we are byte-sized */ - if (size > 1) - { - int halfsize = size / 2; - UINT64 r0, r1; + int halfsize = size / 2; + UINT64 r0, r1; - /* read each half, from lower address to upper address */ - r0 = expression_read_memory_region(rgnindex, rgntype, address + 0, halfsize); - r1 = expression_read_memory_region(rgnindex, rgntype, address + halfsize, halfsize); + /* read each half, from lower address to upper address */ + r0 = expression_read_memory_region(rgnclass, rgntag, address + 0, halfsize); + r1 = expression_read_memory_region(rgnclass, rgntag, address + halfsize, halfsize); - /* assemble based on the target endianness */ - if ((flags & ROMREGION_ENDIANMASK) == ROMREGION_LE) - result = r0 | (r1 << (8 * halfsize)); - else - result = r1 | (r0 << (8 * halfsize)); - } + /* assemble based on the target endianness */ + if ((flags & ROMREGION_ENDIANMASK) == ROMREGION_LE) + result = r0 | (r1 << (8 * halfsize)); + else + result = r1 | (r0 << (8 * halfsize)); + } - /* only process if we're within range */ - else if (address < length) - { - /* lowmask specified which address bits are within the databus width */ - UINT32 lowmask = (1 << (flags & ROMREGION_WIDTHMASK)) - 1; - base += address & ~lowmask; + /* only process if we're within range */ + else if (address < length) + { + /* lowmask specified which address bits are within the databus width */ + UINT32 lowmask = (1 << ((flags & ROMREGION_WIDTHMASK) >> 8)) - 1; + base += address & ~lowmask; - /* if we have a valid base, return the appropriate byte */ - if ((flags & ROMREGION_ENDIANMASK) == ROMREGION_LE) - result = base[BYTE8_XOR_LE(address) & lowmask]; - else - result = base[BYTE8_XOR_BE(address) & lowmask]; - } + /* if we have a valid base, return the appropriate byte */ + if ((flags & ROMREGION_ENDIANMASK) == ROMREGION_LE) + result = base[BYTE8_XOR_LE(address) & lowmask]; + else + result = base[BYTE8_XOR_BE(address) & lowmask]; } } return result; @@ -2360,7 +2361,7 @@ static UINT64 expression_read_eeprom(offs_t address, int size) space -------------------------------------------------*/ -static void expression_write_memory(int space, int index, UINT32 address, int size, UINT64 data) +static void expression_write_memory(const char *name, int space, UINT32 address, int size, UINT64 data) { int cpuindex; @@ -2369,14 +2370,17 @@ static void expression_write_memory(int space, int index, UINT32 address, int si case EXPSPACE_PROGRAM: case EXPSPACE_DATA: case EXPSPACE_IO: - cpuindex = (index == -1) ? cpu_getactivecpu() : index; - space = ADDRESS_SPACE_PROGRAM + (space - EXPSPACE_PROGRAM); - expression_write_address_space(cpuindex, space, address, size, data); + cpuindex = (name != NULL) ? mame_find_cpu_index(Machine, name) : cpu_getactivecpu(); + if (cpuindex < 0) + break; + expression_write_address_space(cpuindex, ADDRESS_SPACE_PROGRAM + (space - EXPSPACE_PROGRAM), address, size, data); break; case EXPSPACE_OPCODE: case EXPSPACE_RAMWRITE: - cpuindex = (index == -1) ? cpu_getactivecpu() : index; + cpuindex = (name != NULL) ? mame_find_cpu_index(Machine, name) : cpu_getactivecpu(); + if (cpuindex < 0) + break; expression_write_program_direct(cpuindex, (space == EXPSPACE_OPCODE), address, size, data); break; @@ -2385,13 +2389,27 @@ static void expression_write_memory(int space, int index, UINT32 address, int si break; case EXPSPACE_CPU: + if (name == NULL) + break; + expression_write_memory_region(RGNCLASS_CPU, name, address, size, data); + break; + case EXPSPACE_USER: + if (name == NULL) + break; + expression_write_memory_region(RGNCLASS_USER, name, address, size, data); + break; + case EXPSPACE_GFX: + if (name == NULL) + break; + expression_write_memory_region(RGNCLASS_GFX, name, address, size, data); + break; + case EXPSPACE_SOUND: - if (index < 1) + if (name == NULL) break; - space = ADDRESS_SPACE_PROGRAM + (space - EXPSPACE_PROGRAM); - expression_write_memory_region(index, space, address, size, data); + expression_write_memory_region(RGNCLASS_SOUND, name, address, size, data); break; } } @@ -2498,68 +2516,53 @@ static void expression_write_program_direct(int cpuindex, int opcode, offs_t add from a memory region -------------------------------------------------*/ -static void expression_write_memory_region(int rgnindex, int rgntype, offs_t address, int size, UINT64 data) +static void expression_write_memory_region(int rgnclass, const char *rgntag, offs_t address, int size, UINT64 data) { - int rgnnum = -1; - - /* convert to a region number */ - switch (rgntype) - { - case EXPSPACE_CPU: rgnnum = REGION_CPU1 + (rgnindex - 1); break; - case EXPSPACE_USER: rgnnum = REGION_USER1 + (rgnindex - 1); break; - case EXPSPACE_GFX: rgnnum = REGION_GFX1 + (rgnindex - 1); break; - case EXPSPACE_SOUND: rgnnum = REGION_SOUND1 + (rgnindex - 1); break; - } + UINT8 *base = memory_region(Machine, rgnclass, rgntag); - /* process if it exists */ - if (rgnnum != -1) + /* make sure we get a valid base before proceeding */ + if (base != NULL) { - UINT8 *base = memory_region(Machine, rgnnum); + UINT32 length = memory_region_length(Machine, rgnclass, rgntag); + UINT32 flags = memory_region_flags(Machine, rgnclass, rgntag); - /* make sure we get a valid base before proceeding */ - if (base != NULL) + /* call ourself recursively until we are byte-sized */ + if (size > 1) { - UINT32 length = memory_region_length(Machine, rgnnum); - UINT32 flags = memory_region_flags(Machine, rgnnum); + int halfsize = size / 2; + UINT64 r0, r1, halfmask; - /* call ourself recursively until we are byte-sized */ - if (size > 1) + /* break apart based on the target endianness */ + halfmask = ~(UINT64)0 >> (64 - 8 * halfsize); + if ((flags & ROMREGION_ENDIANMASK) == ROMREGION_LE) { - int halfsize = size / 2; - UINT64 r0, r1, halfmask; - - /* break apart based on the target endianness */ - halfmask = ~(UINT64)0 >> (64 - 8 * halfsize); - if ((flags & ROMREGION_ENDIANMASK) == ROMREGION_LE) - { - r0 = data & halfmask; - r1 = (data >> (8 * halfsize)) & halfmask; - } - else - { - r0 = (data >> (8 * halfsize)) & halfmask; - r1 = data & halfmask; - } - - /* write each half, from lower address to upper address */ - expression_write_memory_region(rgnindex, rgntype, address + 0, halfsize, r0); - expression_write_memory_region(rgnindex, rgntype, address + halfsize, halfsize, r1); + r0 = data & halfmask; + r1 = (data >> (8 * halfsize)) & halfmask; } - - /* only process if we're within range */ - else if (address < length) + else { - /* lowmask specified which address bits are within the databus width */ - UINT32 lowmask = (1 << (flags & ROMREGION_WIDTHMASK)) - 1; - base += address & ~lowmask; - - /* if we have a valid base, set the appropriate byte */ - if ((flags & ROMREGION_ENDIANMASK) == ROMREGION_LE) - base[BYTE8_XOR_LE(address) & lowmask] = data; - else - base[BYTE8_XOR_BE(address) & lowmask] = data; - global.memory_modified = TRUE; + r0 = (data >> (8 * halfsize)) & halfmask; + r1 = data & halfmask; } + + /* write each half, from lower address to upper address */ + expression_write_memory_region(rgnclass, rgntag, address + 0, halfsize, r0); + expression_write_memory_region(rgnclass, rgntag, address + halfsize, halfsize, r1); + } + + /* only process if we're within range */ + else if (address < length) + { + /* lowmask specified which address bits are within the databus width */ + UINT32 lowmask = (1 << ((flags & ROMREGION_WIDTHMASK) >> 8)) - 1; + base += address & ~lowmask; + + /* if we have a valid base, set the appropriate byte */ + if ((flags & ROMREGION_ENDIANMASK) == ROMREGION_LE) + base[BYTE8_XOR_LE(address) & lowmask] = data; + else + base[BYTE8_XOR_BE(address) & lowmask] = data; + global.memory_modified = TRUE; } } } diff --git a/src/emu/debug/debugvw.c b/src/emu/debug/debugvw.c index b2df25091bb..cf395629614 100644 --- a/src/emu/debug/debugvw.c +++ b/src/emu/debug/debugvw.c @@ -2380,7 +2380,7 @@ static void memory_write_byte(debug_view_memory *memdata, offs_t offs, UINT8 dat /* hack for FD1094 editing */ #ifdef FD1094_HACK - if (memdata->raw_base == memory_region(machine, REGION_USER2)) + if (memdata->raw_base == memory_region(machine, RGNCLASS_USER, "user2")) { extern void fd1094_regenerate_key(void); fd1094_regenerate_key(); diff --git a/src/emu/debug/express.c b/src/emu/debug/express.c index 829ee1f3647..06b30063e91 100644 --- a/src/emu/debug/express.c +++ b/src/emu/debug/express.c @@ -31,7 +31,6 @@ #define MAX_TOKENS 128 #define MAX_STACK_DEPTH 128 #define MAX_STRING_LENGTH 256 -#define MAX_EXPRESSION_STRINGS 64 #define MAX_SYMBOL_LENGTH 64 #define SYM_TABLE_HASH_SIZE 97 @@ -94,7 +93,7 @@ enum TIN_MEMORY_SOUND = (EXPSPACE_SOUND << TIN_MEMORY_SPACE_SHIFT), TIN_MEMORY_INDEX_SHIFT = 16, - TIN_MEMORY_INDEX_MASK = (0xf << TIN_MEMORY_INDEX_SHIFT) + TIN_MEMORY_INDEX_MASK = (0xffff << TIN_MEMORY_INDEX_SHIFT) }; @@ -192,13 +191,23 @@ struct _symbol_table }; +typedef struct _expression_string expression_string; +struct _expression_string +{ + expression_string * next; /* pointer to next string */ + UINT16 index; /* index of this string */ + char string[1]; /* string data */ +}; + + /* typedef struct _parsed_expression parsed_expression -- defined in express.h */ struct _parsed_expression { const symbol_table * table; /* symbol table */ char * original_string; /* original string (prior to parsing) */ express_callbacks callbacks; /* callbacks */ - char * string[MAX_EXPRESSION_STRINGS]; /* string table */ + expression_string * stringlist; /* string list */ + UINT16 stringcount; /* number of strings allocated so far */ parse_token token[MAX_TOKENS]; /* array of tokens */ int token_stack_ptr; /* stack poointer */ parse_token token_stack[MAX_STACK_DEPTH]; /* token stack */ @@ -207,6 +216,15 @@ struct _parsed_expression /*************************************************************************** + PROTOTYPES +***************************************************************************/ + +static char *add_expression_string(parsed_expression *expr, const char *string, int length, UINT16 *index); +static const char *get_expression_string(parsed_expression *expr, UINT16 index); + + + +/*************************************************************************** STACK MANIPULATION ***************************************************************************/ @@ -328,14 +346,12 @@ INLINE EXPRERR pop_token_rval(parsed_expression *expr, parse_token *token, const /* memory tokens get resolved down to number tokens */ else if (token->type == TOK_MEMORY) { - int index = (token->info & TIN_MEMORY_INDEX_MASK) >> TIN_MEMORY_INDEX_SHIFT; + const char *name = get_expression_string(expr, (token->info & TIN_MEMORY_INDEX_MASK) >> TIN_MEMORY_INDEX_SHIFT); int space = (token->info & TIN_MEMORY_SPACE_MASK) >> TIN_MEMORY_SPACE_SHIFT; int size = (token->info & TIN_MEMORY_SIZE_MASK) >> TIN_MEMORY_SIZE_SHIFT; - if ((token->info & TIN_MEMORY_INDEX_MASK) == TIN_MEMORY_INDEX_MASK) - index = -1; token->type = TOK_NUMBER; if (expr->callbacks.read != NULL) - token->value.i = (*expr->callbacks.read)(space, index, token->value.i, 1 << size); + token->value.i = (*expr->callbacks.read)(name, space, token->value.i, 1 << size); else token->value.i = 0; } @@ -362,13 +378,11 @@ INLINE UINT64 get_lval_value(parsed_expression *expr, parse_token *token, const } else if (token->type == TOK_MEMORY) { - int index = (token->info & TIN_MEMORY_INDEX_MASK) >> TIN_MEMORY_INDEX_SHIFT; + const char *name = get_expression_string(expr, (token->info & TIN_MEMORY_INDEX_MASK) >> TIN_MEMORY_INDEX_SHIFT); int space = (token->info & TIN_MEMORY_SPACE_MASK) >> TIN_MEMORY_SPACE_SHIFT; int size = (token->info & TIN_MEMORY_SIZE_MASK) >> TIN_MEMORY_SIZE_SHIFT; - if ((token->info & TIN_MEMORY_INDEX_MASK) == TIN_MEMORY_INDEX_MASK) - index = -1; if (expr->callbacks.read != NULL) - return (*expr->callbacks.read)(space, index, token->value.i, 1 << size); + return (*expr->callbacks.read)(name, space, token->value.i, 1 << size); } return 0; } @@ -389,13 +403,11 @@ INLINE void set_lval_value(parsed_expression *expr, parse_token *token, const sy } else if (token->type == TOK_MEMORY) { - int index = (token->info & TIN_MEMORY_INDEX_MASK) >> TIN_MEMORY_INDEX_SHIFT; + const char *name = get_expression_string(expr, (token->info & TIN_MEMORY_INDEX_MASK) >> TIN_MEMORY_INDEX_SHIFT); int space = (token->info & TIN_MEMORY_SPACE_MASK) >> TIN_MEMORY_SPACE_SHIFT; int size = (token->info & TIN_MEMORY_SIZE_MASK) >> TIN_MEMORY_SIZE_SHIFT; - if ((token->info & TIN_MEMORY_INDEX_MASK) == TIN_MEMORY_INDEX_MASK) - index = -1; if (expr->callbacks.write != NULL) - (*expr->callbacks.write)(space, index, token->value.i, 1 << size, value); + (*expr->callbacks.write)(name, space, token->value.i, 1 << size, value); } } @@ -509,21 +521,31 @@ static void print_tokens(FILE *out, parsed_expression *expr) forms of memory operators -------------------------------------------------*/ -static int parse_memory_operator(const char *buffer, token_info *flags) +static int parse_memory_operator(parsed_expression *expr, const char *buffer, token_info *flags) { - int length = (int)strlen(buffer); int space = 'p', size; - int index = -1; + const char *dot; + int length; *flags = 0; - - /* length 2 or more means space, optional index, then size */ - if (length >= 2) + + /* if there is a '.', it means we have a name */ + dot = strrchr(buffer, '.'); + if (dot != NULL) + { + UINT16 index; + if (!add_expression_string(expr, buffer, dot - buffer, &index)) + return 0; + *flags |= index << TIN_MEMORY_INDEX_SHIFT; + buffer = dot + 1; + } + + /* length 2 means space then size */ + length = (int)strlen(buffer); + if (length == 2) { space = buffer[0]; - if (length >= 3) - sscanf(&buffer[1], "%d", &index); - size = buffer[length - 1]; + size = buffer[1]; } /* length 1 means size */ @@ -560,9 +582,6 @@ static int parse_memory_operator(const char *buffer, token_info *flags) default: return 0; } - /* add the index to flags */ - *flags |= index << TIN_MEMORY_INDEX_SHIFT; - return 1; } @@ -732,14 +751,7 @@ static EXPRERR parse_string_into_tokens(const char *stringstart, parsed_expressi case '"': { char buffer[MAX_STRING_LENGTH]; - int bufindex = 0, strindex; - - /* find a free string entry */ - for (strindex = 0; strindex < MAX_EXPRESSION_STRINGS; strindex++) - if (expr->string[strindex] == NULL) - break; - if (strindex == MAX_EXPRESSION_STRINGS) - return MAKE_EXPRERR_TOO_MANY_STRINGS(token->offset); + int bufindex = 0; /* accumulate a copy of the string */ string++; @@ -760,16 +772,11 @@ static EXPRERR parse_string_into_tokens(const char *stringstart, parsed_expressi return MAKE_EXPRERR_UNBALANCED_QUOTES(token->offset); string++; - /* terminate the string and allocate memory */ - buffer[bufindex++] = 0; - expr->string[strindex] = malloc(bufindex); - if (!expr->string[strindex]) + /* make the token */ + token->value.p = add_expression_string(expr, buffer, bufindex, NULL); + if (token->value.p == NULL) return MAKE_EXPRERR_OUT_OF_MEMORY(token->offset); - - /* copy the string in and make the token */ - strcpy(expr->string[strindex], buffer); token->type = TOK_STRING; - token->value.p = expr->string[strindex]; break; } @@ -825,7 +832,7 @@ static EXPRERR parse_string_into_tokens(const char *stringstart, parsed_expressi if (string[0] == '@') { token_info info; - if (parse_memory_operator(buffer, &info)) + if (parse_memory_operator(expr, buffer, &info)) { SET_TOKEN_INFO(1, TOK_OPERATOR, TVL_MEMORYAT, TIN_PRECEDENCE_2 | info); break; @@ -1599,26 +1606,73 @@ static EXPRERR execute_tokens(parsed_expression *expr, UINT64 *result) ***************************************************************************/ /*------------------------------------------------- + add_expression_string - add a string to the + list of expression strings +-------------------------------------------------*/ + +static char *add_expression_string(parsed_expression *expr, const char *string, int length, UINT16 *index) +{ + expression_string *expstring; + + /* allocate memory */ + expstring = malloc(sizeof(expression_string) + length); + if (expstring == NULL) + return NULL; + + /* make the new string and link it in; we guarantee tha the index is never 0 */ + expstring->next = expr->stringlist; + expstring->index = ++expr->stringcount; + memcpy(expstring->string, string, length); + expstring->string[length] = 0; + expr->stringlist = expstring; + + /* return a pointer to the copied string */ + if (index != NULL) + *index = expstring->index; + return expstring->string; +} + + +/*------------------------------------------------- + get_expression_string - return an indexed + expression string +-------------------------------------------------*/ + +static const char *get_expression_string(parsed_expression *expr, UINT16 index) +{ + expression_string *expstring; + + /* a 0 index is always invalid */ + if (index == 0) + return NULL; + + /* scan for the string with the matching index */ + for (expstring = expr->stringlist; expstring != NULL; expstring = expstring->next) + if (expstring->index == index) + return expstring->string; + return NULL; +} + + +/*------------------------------------------------- free_expression_strings - free all strings allocated to an expression -------------------------------------------------*/ static void free_expression_strings(parsed_expression *expr) { - int strindex; - /* free the original expression */ if (expr->original_string != NULL) free(expr->original_string); expr->original_string = NULL; /* free all strings */ - for (strindex = 0; strindex < MAX_EXPRESSION_STRINGS; strindex++) - if (expr->string[strindex] != NULL) - { - free(expr->string[strindex]); - expr->string[strindex] = NULL; - } + while (expr->stringlist != NULL) + { + expression_string *string = expr->stringlist; + expr->stringlist = string->next; + free(string); + } } @@ -1727,7 +1781,7 @@ EXPRERR expression_execute(parsed_expression *expr, UINT64 *result) void expression_free(parsed_expression *expr) { - if (expr) + if (expr != NULL) { free_expression_strings(expr); free(expr); diff --git a/src/emu/debug/express.h b/src/emu/debug/express.h index 3cae4fd0059..981a140d43f 100644 --- a/src/emu/debug/express.h +++ b/src/emu/debug/express.h @@ -94,8 +94,8 @@ typedef void (*symbol_setter_func)(UINT32 ref, UINT64 value); typedef UINT64 (*function_execute_func)(UINT32 ref, UINT32 numparams, const UINT64 *paramlist); /* callback function for memory reads/writes */ -typedef UINT64 (*express_read_func)(int space, int index, UINT32 offset, int size); -typedef void (*express_write_func)(int space, int index, UINT32 offset, int size, UINT64 value); +typedef UINT64 (*express_read_func)(const char *name, int space, UINT32 offset, int size); +typedef void (*express_write_func)(const char *name, int space, UINT32 offset, int size, UINT64 value); /* callback parameter for executing expressions */ diff --git a/src/emu/drawgfx.h b/src/emu/drawgfx.h index 9cb65fac47f..3e4e4d195ef 100644 --- a/src/emu/drawgfx.h +++ b/src/emu/drawgfx.h @@ -97,7 +97,7 @@ enum #define GFXDECODE_START( name ) const gfx_decode_entry gfxdecodeinfo_##name[] = { #define GFXDECODE_ENTRY(region,offset,layout,start,colors) { region, offset, &layout, start, colors, 0, 0 }, #define GFXDECODE_SCALE(region,offset,layout,start,colors,xscale,yscale) { region, offset, &layout, start, colors, xscale, yscale }, -#define GFXDECODE_END { -1 } }; +#define GFXDECODE_END { 0 } }; /* these macros are used for declaring gfx_layout structures. */ #define GFXLAYOUT_RAW( name, planes, width, height, linemod, charmod ) \ @@ -149,9 +149,9 @@ struct _gfx_element typedef struct _gfx_decode_entry gfx_decode_entry; struct _gfx_decode_entry { - int memory_region; /* memory region where the data resides; -1 marks the end of array */ + const char * memory_region; /* RGNCLASS_GFX memory region where the data resides */ UINT32 start; /* offset of beginning of data to decode */ - const gfx_layout *gfxlayout; /* pointer to gfx_layout describing the layout */ + const gfx_layout *gfxlayout; /* pointer to gfx_layout describing the layout; NULL marks the end of the array */ UINT16 color_codes_start; /* offset in the color lookup table where color codes start */ UINT16 total_color_codes; /* total number of color codes */ UINT8 xscale; /* optional horizontal scaling factor; 0 means 1x */ diff --git a/src/emu/drivers/empty.c b/src/emu/drivers/empty.c index 1356ab4f25d..9ea78d2888a 100644 --- a/src/emu/drivers/empty.c +++ b/src/emu/drivers/empty.c @@ -54,7 +54,7 @@ MACHINE_DRIVER_END *************************************/ ROM_START( empty ) - ROM_REGION( 0x10, REGION_USER1, 0 ) + ROM_REGION( 0x10, RGNCLASS_USER, "user1", 0 ) ROM_END diff --git a/src/emu/info.c b/src/emu/info.c index 3c7dcf1c949..b8240fd786d 100644 --- a/src/emu/info.c +++ b/src/emu/info.c @@ -338,8 +338,8 @@ static void print_game_bios(FILE *out, const game_driver *game) for (rom = game->rom; !ROMENTRY_ISEND(rom); rom++) if (ROMENTRY_ISSYSTEM_BIOS(rom)) { - const char *name = ROM_GETHASHDATA(rom); - const char *description = name + strlen(name) + 1; + const char *name = ROM_GETNAME(rom); + const char *description = ROM_GETHASHDATA(rom); /* output extracted name and descriptions */ fprintf(out, "\t\t<biosset"); @@ -426,7 +426,7 @@ static void print_game_rom(FILE *out, const game_driver *game) for (brom = rom - 1; brom != game->rom; brom--) if (ROMENTRY_ISSYSTEM_BIOS(brom)) { - strcpy(bios_name, ROM_GETHASHDATA(brom)); + strcpy(bios_name, ROM_GETNAME(brom)); break; } } @@ -460,57 +460,7 @@ static void print_game_rom(FILE *out, const game_driver *game) } /* append a region name */ - switch (ROMREGION_GETTYPE(region)) - { - case REGION_CPU1: fprintf(out, " region=\"cpu1\""); break; - case REGION_CPU2: fprintf(out, " region=\"cpu2\""); break; - case REGION_CPU3: fprintf(out, " region=\"cpu3\""); break; - case REGION_CPU4: fprintf(out, " region=\"cpu4\""); break; - case REGION_CPU5: fprintf(out, " region=\"cpu5\""); break; - case REGION_CPU6: fprintf(out, " region=\"cpu6\""); break; - case REGION_CPU7: fprintf(out, " region=\"cpu7\""); break; - case REGION_CPU8: fprintf(out, " region=\"cpu8\""); break; - case REGION_GFX1: fprintf(out, " region=\"gfx1\""); break; - case REGION_GFX2: fprintf(out, " region=\"gfx2\""); break; - case REGION_GFX3: fprintf(out, " region=\"gfx3\""); break; - case REGION_GFX4: fprintf(out, " region=\"gfx4\""); break; - case REGION_GFX5: fprintf(out, " region=\"gfx5\""); break; - case REGION_GFX6: fprintf(out, " region=\"gfx6\""); break; - case REGION_GFX7: fprintf(out, " region=\"gfx7\""); break; - case REGION_GFX8: fprintf(out, " region=\"gfx8\""); break; - case REGION_PROMS: fprintf(out, " region=\"proms\""); break; - case REGION_PLDS: fprintf(out, " region=\"plds\""); break; - case REGION_SOUND1: fprintf(out, " region=\"sound1\""); break; - case REGION_SOUND2: fprintf(out, " region=\"sound2\""); break; - case REGION_SOUND3: fprintf(out, " region=\"sound3\""); break; - case REGION_SOUND4: fprintf(out, " region=\"sound4\""); break; - case REGION_SOUND5: fprintf(out, " region=\"sound5\""); break; - case REGION_SOUND6: fprintf(out, " region=\"sound6\""); break; - case REGION_SOUND7: fprintf(out, " region=\"sound7\""); break; - case REGION_SOUND8: fprintf(out, " region=\"sound8\""); break; - case REGION_USER1: fprintf(out, " region=\"user1\""); break; - case REGION_USER2: fprintf(out, " region=\"user2\""); break; - case REGION_USER3: fprintf(out, " region=\"user3\""); break; - case REGION_USER4: fprintf(out, " region=\"user4\""); break; - case REGION_USER5: fprintf(out, " region=\"user5\""); break; - case REGION_USER6: fprintf(out, " region=\"user6\""); break; - case REGION_USER7: fprintf(out, " region=\"user7\""); break; - case REGION_USER8: fprintf(out, " region=\"user8\""); break; - case REGION_USER9: fprintf(out, " region=\"user9\""); break; - case REGION_USER10: fprintf(out, " region=\"user10\""); break; - case REGION_USER11: fprintf(out, " region=\"user11\""); break; - case REGION_USER12: fprintf(out, " region=\"user12\""); break; - case REGION_USER13: fprintf(out, " region=\"user13\""); break; - case REGION_USER14: fprintf(out, " region=\"user14\""); break; - case REGION_USER15: fprintf(out, " region=\"user15\""); break; - case REGION_USER16: fprintf(out, " region=\"user16\""); break; - case REGION_USER17: fprintf(out, " region=\"user17\""); break; - case REGION_USER18: fprintf(out, " region=\"user18\""); break; - case REGION_USER19: fprintf(out, " region=\"user19\""); break; - case REGION_USER20: fprintf(out, " region=\"user20\""); break; - case REGION_DISKS: fprintf(out, " region=\"disks\""); break; - default: fprintf(out, " region=\"0x%x\"", (int)ROMREGION_GETTYPE(region)); break; - } + fprintf(out, " regionclass=\"%s\" regiontag=\"%s\"", memory_region_class_name(ROMREGION_GETCLASS(region), TRUE), ROMREGION_GETTAG(region)); /* add nodump/baddump flags */ if (hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_NO_DUMP)) @@ -956,7 +906,8 @@ void print_mame_xml(FILE *out, const game_driver *const games[], const char *gam "\t\t\t<!ATTLIST rom md5 CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST rom sha1 CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST rom merge CDATA #IMPLIED>\n" - "\t\t\t<!ATTLIST rom region CDATA #IMPLIED>\n" + "\t\t\t<!ATTLIST rom regionclass CDATA #IMPLIED>\n" + "\t\t\t<!ATTLIST rom regiontag CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST rom offset CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST rom status (baddump|nodump|good) \"good\">\n" "\t\t\t<!ATTLIST rom dispose (yes|no) \"no\">\n" @@ -965,7 +916,8 @@ void print_mame_xml(FILE *out, const game_driver *const games[], const char *gam "\t\t\t<!ATTLIST disk md5 CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST disk sha1 CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST disk merge CDATA #IMPLIED>\n" - "\t\t\t<!ATTLIST disk region CDATA #IMPLIED>\n" + "\t\t\t<!ATTLIST disk regionclass CDATA #IMPLIED>\n" + "\t\t\t<!ATTLIST disk regiontag CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST disk index CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST disk status (baddump|nodump|good) \"good\">\n" "\t\t<!ELEMENT sample EMPTY>\n" diff --git a/src/emu/machine/rp5h01.c b/src/emu/machine/rp5h01.c index 6e6ff774b67..ac478d7ea22 100644 --- a/src/emu/machine/rp5h01.c +++ b/src/emu/machine/rp5h01.c @@ -41,7 +41,7 @@ int RP5H01_init( const struct RP5H01_interface *interface ) { for( i = 0; i < intf->num; i++ ) { RP5H01_state[i].counter = 0; RP5H01_state[i].counter_mode = COUNTER_MODE_6_BITS; - RP5H01_state[i].data = &( memory_region( Machine, intf->region[i] )[ intf->offset[i] ] ); + RP5H01_state[i].data = &( memory_region( Machine, RGNCLASS_USER, intf->region[i] )[ intf->offset[i] ] ); RP5H01_state[i].enabled = 0; RP5H01_state[i].old_reset = -1; RP5H01_state[i].old_clock = -1; diff --git a/src/emu/machine/rp5h01.h b/src/emu/machine/rp5h01.h index 9f9fec7dce6..f9afe51d1c3 100644 --- a/src/emu/machine/rp5h01.h +++ b/src/emu/machine/rp5h01.h @@ -6,7 +6,7 @@ struct RP5H01_interface { int num; /* number of chips */ - int region[MAX_RP5H01]; /* memory region where data resides */ + const char *region[MAX_RP5H01]; /* memory region where data resides */ int offset[MAX_RP5H01]; /* memory offset within the above region where data resides */ }; diff --git a/src/emu/mame.c b/src/emu/mame.c index 8700b0ac461..b27fec9ec5c 100644 --- a/src/emu/mame.c +++ b/src/emu/mame.c @@ -113,10 +113,12 @@ typedef struct _region_info region_info; struct _region_info { - UINT8 * base; + region_info * next; + astring * name; UINT32 length; - UINT32 type; UINT32 flags; + UINT8 padding[32 - 2 * sizeof(void *) - 2 * sizeof(UINT32)]; + UINT8 base[1]; }; @@ -161,7 +163,7 @@ struct _mame_private attotime saveload_schedule_time; /* array of memory regions */ - region_info mem_region[MAX_MEMORY_REGIONS]; + region_info * regions[RGNCLASS_COUNT]; /* error recovery and exiting */ jmp_buf fatal_error_jmpbuf; @@ -204,58 +206,6 @@ const char mame_disclaimer[] = "images is a violation of copyright law and should be promptly reported to the\n" "authors so that appropriate legal action can be taken.\n"; -const char *const memory_region_names[REGION_MAX] = -{ - "REGION_INVALID", - "REGION_CPU1", - "REGION_CPU2", - "REGION_CPU3", - "REGION_CPU4", - "REGION_CPU5", - "REGION_CPU6", - "REGION_CPU7", - "REGION_CPU8", - "REGION_GFX1", - "REGION_GFX2", - "REGION_GFX3", - "REGION_GFX4", - "REGION_GFX5", - "REGION_GFX6", - "REGION_GFX7", - "REGION_GFX8", - "REGION_PROMS", - "REGION_SOUND1", - "REGION_SOUND2", - "REGION_SOUND3", - "REGION_SOUND4", - "REGION_SOUND5", - "REGION_SOUND6", - "REGION_SOUND7", - "REGION_SOUND8", - "REGION_USER1", - "REGION_USER2", - "REGION_USER3", - "REGION_USER4", - "REGION_USER5", - "REGION_USER6", - "REGION_USER7", - "REGION_USER8", - "REGION_USER9", - "REGION_USER10", - "REGION_USER11", - "REGION_USER12", - "REGION_USER13", - "REGION_USER14", - "REGION_USER15", - "REGION_USER16", - "REGION_USER17", - "REGION_USER18", - "REGION_USER19", - "REGION_USER20", - "REGION_DISKS", - "REGION_PLDS" -}; - /*************************************************************************** @@ -805,132 +755,189 @@ int mame_is_paused(running_machine *machine) ***************************************************************************/ /*------------------------------------------------- - memory_region_to_index - returns an index - given either an index or a REGION_* identifier + memory_region_alloc - allocates memory for a + region -------------------------------------------------*/ -static int memory_region_to_index(mame_private *mame, int num) +UINT8 *memory_region_alloc(running_machine *machine, int rgnclass, const char *name, UINT32 length, UINT32 flags) { - int i; - - /* if we're already an index, stop there */ - if (num < MAX_MEMORY_REGIONS) - return num; - - /* scan for a match */ - for (i = 0; i < MAX_MEMORY_REGIONS; i++) - if (mame->mem_region[i].type == num) - return i; - - return -1; + mame_private *mame = machine->mame_data; + region_info *info; + + assert(rgnclass < RGNCLASS_COUNT); + + /* make sure we don't have a region of the same name */ + for (info = mame->regions[rgnclass]; info != NULL; info = info->next) + if (astring_cmpc(info->name, name) == 0) + fatalerror("memory_region_alloc called with duplicate region type %d name \"%s\"\n", rgnclass, name); + + /* allocate the region */ + info = malloc_or_die(sizeof(*info) + length); + info->next = mame->regions[rgnclass]; + info->name = astring_dupc(name); + info->length = length; + info->flags = flags; + + /* hook us into the list */ + mame->regions[rgnclass] = info; + return info->base; } /*------------------------------------------------- - new_memory_region - allocates memory for a + memory_region_free - releases memory for a region -------------------------------------------------*/ -UINT8 *new_memory_region(running_machine *machine, int type, UINT32 length, UINT32 flags) +void memory_region_free(running_machine *machine, int rgnclass, const char *name) { mame_private *mame = machine->mame_data; - int num; + region_info **infoptr; + + assert(rgnclass < RGNCLASS_COUNT); - assert(type >= MAX_MEMORY_REGIONS); - - /* find a free slot */ - for (num = 0; num < MAX_MEMORY_REGIONS; num++) - if (mame->mem_region[num].base == NULL) + /* find the region */ + for (infoptr = &mame->regions[rgnclass]; *infoptr != NULL; infoptr = &(*infoptr)->next) + if (astring_cmpc((*infoptr)->name, name) == 0) + { + region_info *deleteme = *infoptr; + + /* remove us from the list */ + *infoptr = deleteme->next; + + /* free the region */ + astring_free(deleteme->name); + free(deleteme); break; - if (num < 0) - fatalerror("Out of memory regions!"); - - /* allocate the region */ - mame->mem_region[num].length = length; - mame->mem_region[num].type = type; - mame->mem_region[num].flags = flags; - mame->mem_region[num].base = malloc_or_die(length); - return mame->mem_region[num].base; + } } /*------------------------------------------------- - free_memory_region - releases memory for a + memory_region - returns pointer to a memory region -------------------------------------------------*/ -void free_memory_region(running_machine *machine, int num) +UINT8 *memory_region(running_machine *machine, int rgnclass, const char *name) { mame_private *mame = machine->mame_data; - - /* convert to an index and bail if invalid */ - num = memory_region_to_index(mame, num); - if (num < 0) - return; - - /* free the region in question */ - free(mame->mem_region[num].base); - memset(&mame->mem_region[num], 0, sizeof(mame->mem_region[num])); + region_info *info; + + assert(rgnclass < RGNCLASS_COUNT); + + /* NULL tag always fails */ + if (name == NULL) + return NULL; + + /* make sure we don't have a region of the same name */ + for (info = mame->regions[rgnclass]; info != NULL; info = info->next) + if (astring_cmpc(info->name, name) == 0) + return info->base; + + return NULL; } /*------------------------------------------------- - memory_region - returns pointer to a memory - region + memory_region_length - returns length of a + memory region -------------------------------------------------*/ -UINT8 *memory_region(running_machine *machine, int num) +UINT32 memory_region_length(running_machine *machine, int rgnclass, const char *name) { mame_private *mame = machine->mame_data; - - /* convert to an index and return the result */ - num = memory_region_to_index(mame, num); - return (num >= 0) ? mame->mem_region[num].base : NULL; + region_info *info; + + assert(rgnclass < RGNCLASS_COUNT); + + /* NULL tag always fails */ + if (name == NULL) + return 0; + + /* make sure we don't have a region of the same name */ + for (info = mame->regions[rgnclass]; info != NULL; info = info->next) + if (astring_cmpc(info->name, name) == 0) + return info->length; + + return 0; } /*------------------------------------------------- - memory_region_length - returns length of a + memory_region_flags - returns flags for a memory region -------------------------------------------------*/ -UINT32 memory_region_length(running_machine *machine, int num) +UINT32 memory_region_flags(running_machine *machine, int rgnclass, const char *name) { mame_private *mame = machine->mame_data; - - /* convert to an index and return the result */ - num = memory_region_to_index(mame, num); - return (num >= 0) ? mame->mem_region[num].length : 0; + region_info *info; + + assert(rgnclass < RGNCLASS_COUNT); + + /* NULL tag always fails */ + if (name == NULL) + return 0; + + /* make sure we don't have a region of the same name */ + for (info = mame->regions[rgnclass]; info != NULL; info = info->next) + if (astring_cmpc(info->name, name) == 0) + return info->flags; + + return 0; } /*------------------------------------------------- - memory_region_type - returns the type of a - memory region + memory_region_next - the name of the next + memory region of the same class (or the first + if name == NULL) -------------------------------------------------*/ -UINT32 memory_region_type(running_machine *machine, int num) +const char *memory_region_next(running_machine *machine, int rgnclass, const char *name) { mame_private *mame = machine->mame_data; - - /* convert to an index and return the result */ - num = memory_region_to_index(mame, num); - return (num >= 0) ? mame->mem_region[num].type : 0; + region_info *info; + + assert(rgnclass < RGNCLASS_COUNT); + + /* if there's nothing in this class, fail immediately */ + info = mame->regions[rgnclass]; + if (info == NULL) + return NULL; + + /* NULL means return the first */ + if (name == NULL) + return astring_c(info->name); + + /* make sure we don't have a region of the same name */ + for ( ; info != NULL; info = info->next) + if (astring_cmpc(info->name, name) == 0) + return (info->next != NULL) ? astring_c(info->next->name) : NULL; + + return NULL; } /*------------------------------------------------- - memory_region_flags - returns flags for a - memory region + memory_region_class_name - return the name of + the given memory region class -------------------------------------------------*/ -UINT32 memory_region_flags(running_machine *machine, int num) +const char *memory_region_class_name(int rgnclass, int lowercase) { - mame_private *mame = machine->mame_data; - - /* convert to an index and return the result */ - num = memory_region_to_index(mame, num); - return (num >= 0) ? mame->mem_region[num].flags : 0; + switch (rgnclass) + { + default: return lowercase ? "unknown" : "Unknown"; + case RGNCLASS_CPU: return lowercase ? "cpu" : "CPU"; + case RGNCLASS_GFX: return lowercase ? "gfx" : "Gfx"; + case RGNCLASS_SOUND: return lowercase ? "sound" : "Sound"; + case RGNCLASS_USER: return lowercase ? "user" : "User"; + case RGNCLASS_DISKS: return lowercase ? "disk" : "Disk"; + case RGNCLASS_PROMS: return lowercase ? "prom" : "PROM"; + case RGNCLASS_PLDS: return lowercase ? "pld" : "PLD"; + } + return NULL; } @@ -1520,8 +1527,9 @@ static void destroy_machine(running_machine *machine) static void init_machine(running_machine *machine) { mame_private *mame = machine->mame_data; + const char *rgntag, *nextrgntag; time_t newbase; - int num; + int rgnclass; /* initialize basic can't-fail systems here */ cpuintrf_init(machine); @@ -1613,9 +1621,13 @@ static void init_machine(running_machine *machine) (*machine->config->video_start)(machine); /* free memory regions allocated with REGIONFLAG_DISPOSE (typically gfx roms) */ - for (num = 0; num < MAX_MEMORY_REGIONS; num++) - if (mame->mem_region[num].flags & ROMREGION_DISPOSE) - free_memory_region(machine, num); + for (rgnclass = 0; rgnclass < RGNCLASS_COUNT; rgnclass++) + for (rgntag = memory_region_next(machine, rgnclass, NULL); rgntag != NULL; rgntag = nextrgntag) + { + nextrgntag = memory_region_next(machine, rgnclass, rgntag); + if (memory_region_flags(machine, rgnclass, rgntag) & ROMREGION_DISPOSE) + memory_region_free(machine, rgnclass, rgntag); + } /* initialize miscellaneous systems */ saveload_init(machine); diff --git a/src/emu/mame.h b/src/emu/mame.h index 79e74002aa6..47a285d6e8a 100644 --- a/src/emu/mame.h +++ b/src/emu/mame.h @@ -114,62 +114,20 @@ enum _output_channel typedef enum _output_channel output_channel; -/* memory region types */ +/* memory region classes */ enum { - REGION_INVALID = 0x80, - REGION_CPU1, - REGION_CPU2, - REGION_CPU3, - REGION_CPU4, - REGION_CPU5, - REGION_CPU6, - REGION_CPU7, - REGION_CPU8, - REGION_GFX1, - REGION_GFX2, - REGION_GFX3, - REGION_GFX4, - REGION_GFX5, - REGION_GFX6, - REGION_GFX7, - REGION_GFX8, - REGION_PROMS, - REGION_SOUND1, - REGION_SOUND2, - REGION_SOUND3, - REGION_SOUND4, - REGION_SOUND5, - REGION_SOUND6, - REGION_SOUND7, - REGION_SOUND8, - REGION_USER1, - REGION_USER2, - REGION_USER3, - REGION_USER4, - REGION_USER5, - REGION_USER6, - REGION_USER7, - REGION_USER8, - REGION_USER9, - REGION_USER10, - REGION_USER11, - REGION_USER12, - REGION_USER13, - REGION_USER14, - REGION_USER15, - REGION_USER16, - REGION_USER17, - REGION_USER18, - REGION_USER19, - REGION_USER20, - REGION_DISKS, - REGION_PLDS, - REGION_MAX + RGNCLASS_INVALID = 0x00, + RGNCLASS_CPU, + RGNCLASS_GFX, + RGNCLASS_SOUND, + RGNCLASS_USER, + RGNCLASS_DISKS, + RGNCLASS_PROMS, + RGNCLASS_PLDS, + RGNCLASS_COUNT }; -extern const char *const memory_region_names[REGION_MAX]; - /*************************************************************************** @@ -340,22 +298,25 @@ int mame_is_paused(running_machine *machine); /* ----- memory region management ----- */ /* allocate a new memory region */ -UINT8 *new_memory_region(running_machine *machine, int type, UINT32 length, UINT32 flags); +UINT8 *memory_region_alloc(running_machine *machine, int rgnclass, const char *name, UINT32 length, UINT32 flags); /* free an allocated memory region */ -void free_memory_region(running_machine *machine, int num); +void memory_region_free(running_machine *machine, int rgnclass, const char *name); /* return a pointer to a specified memory region */ -UINT8 *memory_region(running_machine *machine, int num); +UINT8 *memory_region(running_machine *machine, int rgnclass, const char *name); /* return the size (in bytes) of a specified memory region */ -UINT32 memory_region_length(running_machine *machine, int num); - -/* return the type of a specified memory region */ -UINT32 memory_region_type(running_machine *machine, int num); +UINT32 memory_region_length(running_machine *machine, int rgnclass, const char *name); /* return the flags (defined in romload.h) for a specified memory region */ -UINT32 memory_region_flags(running_machine *machine, int num); +UINT32 memory_region_flags(running_machine *machine, int rgnclass, const char *name); + +/* return the name of the next memory region of the same class (or the first if name == NULL) */ +const char *memory_region_next(running_machine *machine, int rgnclass, const char *name); + +/* return the name of the given memory region class */ +const char *memory_region_class_name(int rgnclass, int lowercase); diff --git a/src/emu/memory.c b/src/emu/memory.c index e7a60c9757a..adeeb042351 100644 --- a/src/emu/memory.c +++ b/src/emu/memory.c @@ -90,7 +90,7 @@ through the given callback handler. Special static values representing RAM, ROM, or BANKs are also allowed here. - AM_REGION(region, offs) + AM_REGION(class, tag, offs) Only useful if AM_READ/WRITE point to RAM, ROM, or BANK memory. By default, memory is allocated to back each bucket. By specifying AM_REGION, you can tell the memory system to point the base of the @@ -280,6 +280,7 @@ struct _addrspace_data typedef struct _cpu_data cpu_data; struct _cpu_data { + const char * tag; /* CPU's tag */ UINT8 * region; /* pointer to memory region */ size_t regionsize; /* size of region, in bytes */ @@ -375,7 +376,7 @@ const char *const address_space_names[ADDRESS_SPACES] = { "program", "data", "I/ static void address_map_detokenize(address_map *map, const addrmap_token *tokens); static void memory_init_cpudata(running_machine *machine); -static void memory_init_preflight(const machine_config *config); +static void memory_init_preflight(running_machine *machine); static void memory_init_populate(running_machine *machine); static void space_map_range_private(addrspace_data *space, read_or_write readorwrite, int handlerbits, int handlerunitmask, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, genf *handler, void *object, const char *handler_name); static void space_map_range(addrspace_data *space, read_or_write readorwrite, int handlerbits, int handlerunitmask, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, genf *handler, void *object, const char *handler_name); @@ -391,8 +392,8 @@ static int subtable_merge(table_data *tabledata); static void subtable_release(table_data *tabledata, UINT8 subentry); static UINT8 *subtable_open(table_data *tabledata, offs_t l1index); static void subtable_close(table_data *tabledata, offs_t l1index); -static void memory_init_allocate(const machine_config *config); -static void *allocate_memory_block(int cpunum, int spacenum, offs_t bytestart, offs_t byteend, void *memory); +static void memory_init_allocate(running_machine *machine); +static void *allocate_memory_block(running_machine *machine, int cpunum, int spacenum, offs_t bytestart, offs_t byteend, void *memory); static void register_for_save(int cpunum, int spacenum, offs_t bytestart, void *base, size_t numbytes); static address_map_entry *assign_intersecting_blocks(addrspace_data *space, offs_t bytestart, offs_t byteend, UINT8 *base); static void memory_init_locate(running_machine *machine); @@ -729,13 +730,13 @@ void memory_init(running_machine *machine) memory_init_cpudata(machine); /* preflight the memory handlers and check banks */ - memory_init_preflight(machine->config); + memory_init_preflight(machine); /* then fill in the tables */ memory_init_populate(machine); /* allocate any necessary memory */ - memory_init_allocate(machine->config); + memory_init_allocate(machine); /* find all the allocated pointers */ memory_init_locate(machine); @@ -1030,7 +1031,8 @@ static void address_map_detokenize(address_map *map, const addrmap_token *tokens case ADDRMAP_TOKEN_REGION: TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT64_UNPACK3(tokens, entrytype, 8, entry->region, 24, entry->region_offs, 32); + TOKEN_GET_UINT64_UNPACK3(tokens, entrytype, 8, entry->rgnclass, 24, entry->rgnoffs, 32); + entry->rgntag = TOKEN_GET_STRING(tokens); break; case ADDRMAP_TOKEN_SHARE: @@ -1615,8 +1617,9 @@ static void memory_init_cpudata(running_machine *machine) cpu_data *cpu = &cpudata[cpunum]; /* get pointers to the CPU's memory region */ - cpu->region = memory_region(Machine, REGION_CPU1 + cpunum); - cpu->regionsize = memory_region_length(Machine, REGION_CPU1 + cpunum); + cpu->tag = config->cpu[cpunum].tag; + cpu->region = memory_region(machine, RGNCLASS_CPU, cpu->tag); + cpu->regionsize = memory_region_length(machine, RGNCLASS_CPU, cpu->tag); /* initialize each address space, and build up a mask of spaces */ for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) @@ -1666,10 +1669,10 @@ static void memory_init_cpudata(running_machine *machine) } /* set the RAM/ROM base */ - cpu->opbase.ram = cpu->opbase.rom = memory_region(Machine, REGION_CPU1 + cpunum); + cpu->opbase.ram = cpu->opbase.rom = cpu->region; cpu->opbase.mask = cpu->space[ADDRESS_SPACE_PROGRAM].bytemask; cpu->opbase.mem_min = 0; - cpu->opbase.mem_max = memory_region_length(Machine, REGION_CPU1 + cpunum); + cpu->opbase.mem_max = cpu->regionsize; cpu->opbase.entry = STATIC_UNMAP; cpu->opbase_handler = NULL; } @@ -1681,7 +1684,7 @@ static void memory_init_cpudata(running_machine *machine) and track which banks are referenced -------------------------------------------------*/ -static void memory_init_preflight(const machine_config *config) +static void memory_init_preflight(running_machine *machine) { int cpunum; @@ -1703,7 +1706,7 @@ static void memory_init_preflight(const machine_config *config) int entrynum; /* allocate the address map */ - space->map = address_map_alloc(config, cpunum, spacenum); + space->map = address_map_alloc(machine->config, cpunum, spacenum); /* extract global parameters specified by the map */ space->unmap = (space->map->unmapval == 0) ? 0 : ~0; @@ -1724,32 +1727,33 @@ 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.generic) && entry->region == 0) + if (spacenum == ADDRESS_SPACE_PROGRAM && HANDLER_IS_ROM(entry->read.generic) && entry->rgntag == NULL) { /* make sure it fits within the memory region before doing so, however */ if (entry->byteend < cpu->regionsize) { - entry->region = REGION_CPU1 + cpunum; - entry->region_offs = entry->bytestart; + entry->rgnclass = RGNCLASS_CPU; + entry->rgntag = cpu->tag; + entry->rgnoffs = entry->bytestart; } } /* validate adjusted addresses against implicit regions */ - if (entry->region != 0 && entry->share == 0 && entry->baseptr == NULL) + if (entry->rgntag != NULL && entry->share == 0 && entry->baseptr == NULL) { - UINT8 *base = memory_region(Machine, entry->region); - offs_t length = memory_region_length(Machine, entry->region); + UINT8 *base = memory_region(machine, entry->rgnclass, entry->rgntag); + offs_t length = memory_region_length(machine, entry->rgnclass, entry->rgntag); /* validate the region */ if (base == NULL) - fatalerror("Error: CPU %d space %d memory map entry %X-%X references non-existant region %d", cpunum, spacenum, entry->addrstart, entry->addrend, entry->region); - if (entry->region_offs + (entry->byteend - entry->bytestart + 1) > length) - fatalerror("Error: CPU %d space %d memory map entry %X-%X extends beyond region %d size (%X)", cpunum, spacenum, entry->addrstart, entry->addrend, entry->region, length); + fatalerror("Error: CPU %d space %d memory map entry %X-%X references non-existant region %d,\"%s\"", cpunum, spacenum, entry->addrstart, entry->addrend, entry->rgnclass, entry->rgntag); + if (entry->rgnoffs + (entry->byteend - entry->bytestart + 1) > length) + fatalerror("Error: CPU %d space %d memory map entry %X-%X extends beyond region %d,\"%s\" size (%X)", cpunum, spacenum, entry->addrstart, entry->addrend, entry->rgnclass, entry->rgntag, length); } /* convert any region-relative entries to their memory pointers */ - if (entry->region != 0) - entry->memory = memory_region(Machine, entry->region) + entry->region_offs; + if (entry->rgntag != NULL) + entry->memory = memory_region(machine, entry->rgnclass, entry->rgntag) + entry->rgnoffs; /* assign static banks for explicitly specified entries */ if (HANDLER_IS_BANK(entry->read.generic)) @@ -2436,7 +2440,7 @@ static int amentry_needs_backing_store(int cpunum, int spacenum, const address_m FPTR handler; if (entry->baseptr != NULL || entry->baseptroffs_plus1 != 0) - return 1; + return TRUE; handler = (FPTR)entry->write.generic; if (handler < STATIC_COUNT) @@ -2445,7 +2449,7 @@ static int amentry_needs_backing_store(int cpunum, int spacenum, const address_m handler != STATIC_ROM && handler != STATIC_NOP && handler != STATIC_UNMAP) - return 1; + return TRUE; } handler = (FPTR)entry->read.generic; @@ -2453,13 +2457,13 @@ static int amentry_needs_backing_store(int cpunum, int spacenum, const address_m { if (handler != STATIC_INVALID && (handler < STATIC_BANK1 || handler > STATIC_BANK1 + MAX_BANKS - 1) && - (handler != STATIC_ROM || spacenum != ADDRESS_SPACE_PROGRAM || entry->addrstart >= memory_region_length(Machine, REGION_CPU1 + cpunum)) && + (handler != STATIC_ROM || spacenum != ADDRESS_SPACE_PROGRAM || entry->addrstart >= cpudata[cpunum].regionsize) && handler != STATIC_NOP && handler != STATIC_UNMAP) - return 1; + return TRUE; } - return 0; + return FALSE; } @@ -2468,7 +2472,7 @@ static int amentry_needs_backing_store(int cpunum, int spacenum, const address_m CPU address spaces -------------------------------------------------*/ -static void memory_init_allocate(const machine_config *config) +static void memory_init_allocate(running_machine *machine) { int cpunum, spacenum; @@ -2487,7 +2491,7 @@ static void memory_init_allocate(const machine_config *config) /* we do this to make sure they are found by memory_find_base first */ for (entry = space->map->entrylist; entry != NULL; entry = entry->next) if (entry->memory != NULL) - allocate_memory_block(cpunum, spacenum, entry->bytestart, entry->byteend, entry->memory); + allocate_memory_block(machine, cpunum, spacenum, entry->bytestart, entry->byteend, entry->memory); /* loop over all blocks just allocated and assign pointers from them */ for (memblock = memory_block_list; memblock != prev_memblock_head; memblock = memblock->next) @@ -2537,7 +2541,7 @@ static void memory_init_allocate(const machine_config *config) /* we now have a block to allocate; do it */ curbytestart = curblockstart * MEMORY_BLOCK_CHUNK; curbyteend = curblockend * MEMORY_BLOCK_CHUNK + (MEMORY_BLOCK_CHUNK - 1); - block = allocate_memory_block(cpunum, spacenum, curbytestart, curbyteend, NULL); + block = allocate_memory_block(machine, cpunum, spacenum, curbytestart, curbyteend, NULL); /* assign memory that intersected the new block */ unassigned = assign_intersecting_blocks(space, curbytestart, curbyteend, block); @@ -2551,12 +2555,14 @@ static void memory_init_allocate(const machine_config *config) memory block of data -------------------------------------------------*/ -static void *allocate_memory_block(int cpunum, int spacenum, offs_t bytestart, offs_t byteend, void *memory) +static void *allocate_memory_block(running_machine *machine, int cpunum, int spacenum, offs_t bytestart, offs_t byteend, void *memory) { int allocatemem = (memory == NULL); memory_block *block; size_t bytestoalloc; - int region; + const char *rgntag; + int foundit = FALSE; + int rgnclass; VPRINTF(("allocate_memory_block(%d,%d,%08X,%08X,%p)\n", cpunum, spacenum, bytestart, byteend, memory)); @@ -2572,17 +2578,19 @@ static void *allocate_memory_block(int cpunum, int spacenum, offs_t bytestart, o memory = block + 1; /* register for saving, but only if we're not part of a memory region */ - for (region = 0; region < MAX_MEMORY_REGIONS; region++) - { - UINT8 *region_base = memory_region(Machine, region); - UINT32 region_length = memory_region_length(Machine, region); - if (region_base != NULL && region_length != 0 && (UINT8 *)memory >= region_base && ((UINT8 *)memory + (byteend - bytestart + 1)) < region_base + region_length) + for (rgnclass = 0; rgnclass < RGNCLASS_COUNT; rgnclass++) + for (rgntag = memory_region_next(machine, rgnclass, NULL); !foundit && rgntag != NULL; rgntag = memory_region_next(machine, rgnclass, rgntag)) { - VPRINTF(("skipping save of this memory block as it is covered by a memory region\n")); - break; + UINT8 *region_base = memory_region(Machine, rgnclass, rgntag); + UINT32 region_length = memory_region_length(Machine, rgnclass, rgntag); + if (region_base != NULL && region_length != 0 && (UINT8 *)memory >= region_base && ((UINT8 *)memory + (byteend - bytestart + 1)) < region_base + region_length) + { + VPRINTF(("skipping save of this memory block as it is covered by a memory region\n")); + foundit = TRUE; + break; + } } - } - if (region == MAX_MEMORY_REGIONS) + if (rgnclass == RGNCLASS_COUNT) register_for_save(cpunum, spacenum, bytestart, memory, byteend - bytestart + 1); /* fill in the tracking block */ diff --git a/src/emu/memory.h b/src/emu/memory.h index 048ff280ac5..a17dfe9cee0 100644 --- a/src/emu/memory.h +++ b/src/emu/memory.h @@ -225,8 +225,9 @@ struct _address_map_entry 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 */ + UINT32 rgnclass; /* class of region containing the memory backing this entry */ + const char * rgntag; /* tag of region containing the memory backing this entry */ + offs_t rgnoffs; /* offset within the region */ void * memory; /* pointer to memory backing this entry */ offs_t bytestart; /* byte-adjusted start address */ @@ -764,8 +765,9 @@ union _addrmap64_token TOKEN_UINT32_PACK3(ADDRMAP_TOKEN_READ_PORT, 8, 0, 8, 0, 8), \ TOKEN_STRING(_tag), -#define AM_REGION(_region, _offs) \ - TOKEN_UINT64_PACK3(ADDRMAP_TOKEN_REGION, 8, _region, 24, _offs, 32), +#define AM_REGION(_class, _tag, _offs) \ + TOKEN_UINT64_PACK3(ADDRMAP_TOKEN_REGION, 8, _class, 24, _offs, 32), \ + TOKEN_STRING(_tag), #define AM_SHARE(_index) \ TOKEN_UINT32_PACK2(ADDRMAP_TOKEN_SHARE, 8, _index, 24), diff --git a/src/emu/romload.c b/src/emu/romload.c index bf31b7d97cb..d2ff24f42c6 100644 --- a/src/emu/romload.c +++ b/src/emu/romload.c @@ -195,7 +195,7 @@ static int determine_bios_rom(rom_load_data *romdata, const rom_entry *romp) for (rom = romp; !ROMENTRY_ISEND(rom); rom++) if (ROMENTRY_ISSYSTEM_BIOS(rom)) { - const char *biosname = ROM_GETHASHDATA(rom); + const char *biosname = ROM_GETNAME(rom); int bios_flags = ROM_GETBIOSFLAGS(rom); char bios_number[20]; @@ -415,17 +415,22 @@ static void display_loading_rom_message(const char *name, rom_load_data *romdata static void display_rom_load_results(rom_load_data *romdata) { - int region; - /* final status display */ display_loading_rom_message(NULL, romdata); /* if we had errors, they are fatal */ if (romdata->errors != 0) { + const char *rgntag, *nextrgntag; + int rgnclass; + /* clean up any regions */ - for (region = 0; region < MAX_MEMORY_REGIONS; region++) - free_memory_region(Machine, region); + for (rgnclass = 0; rgnclass < RGNCLASS_COUNT; rgnclass++) + for (rgntag = memory_region_next(Machine, rgnclass, NULL); rgntag != NULL; rgntag = nextrgntag) + { + nextrgntag = memory_region_next(Machine, rgnclass, rgntag); + memory_region_free(Machine, rgnclass, rgntag); + } /* create the error message and exit fatally */ strcat(romdata->errorbuf, "ERROR: required files are missing, the game cannot be run."); @@ -446,13 +451,13 @@ static void display_rom_load_results(rom_load_data *romdata) byte swapping and inverting data as necessary -------------------------------------------------*/ -static void region_post_process(running_machine *machine, rom_load_data *romdata, int regnum) +static void region_post_process(running_machine *machine, rom_load_data *romdata, int rgnclass, const char *rgntag) { - UINT32 regionlength = memory_region_length(machine, regnum); - UINT32 regionflags = memory_region_flags(machine, regnum); - UINT8 *regionbase = memory_region(machine, regnum); + UINT32 regionlength = memory_region_length(machine, rgnclass, rgntag); + UINT32 regionflags = memory_region_flags(machine, rgnclass, rgntag); + UINT8 *regionbase = memory_region(machine, rgnclass, rgntag); int littleendian = ((regionflags & ROMREGION_ENDIANMASK) == ROMREGION_LE); - int datawidth = 1 << (regionflags & ROMREGION_WIDTHMASK); + int datawidth = 1 << ((regionflags & ROMREGION_WIDTHMASK) >> 8); UINT8 *base; int i, j; @@ -683,7 +688,8 @@ static void fill_rom_data(rom_load_data *romdata, const rom_entry *romp) static void copy_rom_data(rom_load_data *romdata, const rom_entry *romp) { UINT8 *base = romdata->regionbase + ROM_GETOFFSET(romp); - int srcregion = ROM_GETFLAGS(romp) >> 24; + int srcrgnclass = (ROM_GETFLAGS(romp) >> 4) & 0x0f; + const char *srcrgntag = ROM_GETNAME(romp); UINT32 numbytes = ROM_GETLENGTH(romp); UINT32 srcoffs = (FPTR)ROM_GETHASHDATA(romp); /* srcoffset in place of hashdata */ UINT8 *srcbase; @@ -697,12 +703,12 @@ static void copy_rom_data(rom_load_data *romdata, const rom_entry *romp) fatalerror("Error in RomModule definition: COPY has an invalid length\n"); /* make sure the source was valid */ - srcbase = memory_region(Machine, srcregion); - if (!srcbase) + srcbase = memory_region(Machine, srcrgnclass, srcrgntag); + if (srcbase == NULL) fatalerror("Error in RomModule definition: COPY from an invalid region\n"); /* make sure we find within the region space */ - if (srcoffs + numbytes > memory_region_length(Machine, srcregion)) + if (srcoffs + numbytes > memory_region_length(Machine, srcrgnclass, srcrgntag)) fatalerror("Error in RomModule definition: COPY out of source memory region space\n"); /* fill the data */ @@ -1046,30 +1052,33 @@ next: flags for the given CPU index -------------------------------------------------*/ -static UINT32 normalize_flags_for_cpu(running_machine *machine, UINT32 startflags, int cpunum) +static UINT32 normalize_flags_for_cpu(running_machine *machine, UINT32 startflags, const char *rgntag) { - int cputype = machine->config->cpu[cpunum].type; - int buswidth; - - /* set the endianness */ - startflags &= ~ROMREGION_ENDIANMASK; - if (cputype_endianness(cputype) == CPU_IS_LE) - startflags |= ROMREGION_LE; - else - startflags |= ROMREGION_BE; - - /* set the width */ - startflags &= ~ROMREGION_WIDTHMASK; - buswidth = cputype_databus_width(cputype, ADDRESS_SPACE_PROGRAM); - if (buswidth <= 8) - startflags |= ROMREGION_8BIT; - else if (buswidth <= 16) - startflags |= ROMREGION_16BIT; - else if (buswidth <= 32) - startflags |= ROMREGION_32BIT; - else - startflags |= ROMREGION_64BIT; + int cpunum = mame_find_cpu_index(machine, rgntag); + if (cpunum >= 0) + { + int cputype = machine->config->cpu[cpunum].type; + int buswidth; + /* set the endianness */ + startflags &= ~ROMREGION_ENDIANMASK; + if (cputype_endianness(cputype) == CPU_IS_LE) + startflags |= ROMREGION_LE; + else + startflags |= ROMREGION_BE; + + /* set the width */ + startflags &= ~ROMREGION_WIDTHMASK; + buswidth = cputype_databus_width(cputype, ADDRESS_SPACE_PROGRAM); + if (buswidth <= 8) + startflags |= ROMREGION_8BIT; + else if (buswidth <= 16) + startflags |= ROMREGION_16BIT; + else if (buswidth <= 32) + startflags |= ROMREGION_32BIT; + else + startflags |= ROMREGION_64BIT; + } return startflags; } @@ -1081,10 +1090,8 @@ static UINT32 normalize_flags_for_cpu(running_machine *machine, UINT32 startflag void rom_init(running_machine *machine, const rom_entry *romp) { - const rom_entry *regionlist[REGION_MAX]; - const rom_entry *region; static rom_load_data romdata; - int regnum; + const rom_entry *region; /* if no roms, bail */ if (romp == NULL) @@ -1093,9 +1100,6 @@ void rom_init(running_machine *machine, const rom_entry *romp) /* make sure we get called back on the way out */ add_exit_callback(machine, rom_exit); - /* reset the region list */ - memset((void *)regionlist, 0, sizeof(regionlist)); - /* reset the romdata struct */ memset(&romdata, 0, sizeof(romdata)); @@ -1109,23 +1113,24 @@ void rom_init(running_machine *machine, const rom_entry *romp) chd_list_tailptr = &chd_list; /* loop until we hit the end */ - for (region = romp, regnum = 0; region; region = rom_next_region(region), regnum++) + for (region = romp; region; region = rom_next_region(region)) { UINT32 regionlength = ROMREGION_GETLENGTH(region); UINT32 regionflags = ROMREGION_GETFLAGS(region); - int regiontype = ROMREGION_GETTYPE(region); + const char *regiontag = ROMREGION_GETTAG(region); + int regionclass = ROMREGION_GETCLASS(region); - LOG(("Processing region %02X (length=%X)\n", regiontype, regionlength)); + LOG(("Processing region %d,\"%s\" (length=%X)\n", regionclass, regiontag, regionlength)); /* the first entry must be a region */ assert(ROMENTRY_ISREGION(region)); /* if this is a CPU region, override with the CPU width and endianness */ - if (regiontype >= REGION_CPU1 && regiontype < REGION_CPU1 + MAX_CPU) - regionflags = normalize_flags_for_cpu(machine, regionflags, regiontype - REGION_CPU1); + if (regionclass == RGNCLASS_CPU) + regionflags = normalize_flags_for_cpu(machine, regionflags, regiontag); /* remember the base and length */ - romdata.regionbase = new_memory_region(machine, regiontype, regionlength, regionflags); + romdata.regionbase = memory_region_alloc(machine, regionclass, regiontag, regionlength, regionflags); romdata.regionlength = regionlength; LOG(("Allocated %X bytes @ %p\n", romdata.regionlength, romdata.regionbase)); @@ -1149,19 +1154,10 @@ void rom_init(running_machine *machine, const rom_entry *romp) else if (ROMREGION_ISDISKDATA(region)) process_disk_entries(&romdata, region + 1); - /* add this region to the list */ - if (regiontype < REGION_MAX) - regionlist[regiontype] = region; + /* finally, post-process for endianness and inversion */ + region_post_process(machine, &romdata, regionclass, regiontag); } - /* post-process the regions */ - for (regnum = 0; regnum < REGION_MAX; regnum++) - if (regionlist[regnum]) - { - LOG(("Post-processing region %02X\n", regnum)); - region_post_process(machine, &romdata, regnum); - } - /* display the results and exit */ total_rom_load_warnings = romdata.warnings; @@ -1175,12 +1171,17 @@ void rom_init(running_machine *machine, const rom_entry *romp) static void rom_exit(running_machine *machine) { + const char *rgntag, *nextrgntag; open_chd *curchd; - int i; + int rgnclass; /* free the memory allocated for various regions */ - for (i = 0; i < MAX_MEMORY_REGIONS; i++) - free_memory_region(machine, i); + for (rgnclass = 0; rgnclass < RGNCLASS_COUNT; rgnclass++) + for (rgntag = memory_region_next(machine, rgnclass, NULL); rgntag != NULL; rgntag = nextrgntag) + { + nextrgntag = memory_region_next(machine, rgnclass, rgntag); + memory_region_free(machine, rgnclass, rgntag); + } /* close all hard drives */ for (curchd = chd_list; curchd != NULL; curchd = curchd->next) diff --git a/src/emu/romload.h b/src/emu/romload.h index a21502e634e..689a6fe1643 100644 --- a/src/emu/romload.h +++ b/src/emu/romload.h @@ -23,10 +23,12 @@ CONSTANTS ***************************************************************************/ -/* ----- per-entry constants ----- */ +/* ----- type constants ----- */ +#define ROMENTRY_TYPEMASK 0x0000000f /* type of entry */ enum { - ROMENTRYTYPE_REGION = 1, /* this entry marks the start of a region */ + ROMENTRYTYPE_ROM = 0, /* this entry is an actual ROM definition */ + ROMENTRYTYPE_REGION, /* this entry marks the start of a region */ ROMENTRYTYPE_END, /* this entry marks the end of a region */ ROMENTRYTYPE_RELOAD, /* this entry reloads the previous ROM */ ROMENTRYTYPE_CONTINUE, /* this entry continues loading the previous ROM */ @@ -39,81 +41,79 @@ enum }; /* ----- per-region constants ----- */ -#define ROMREGION_WIDTHMASK 0x00000003 /* native width of region, as power of 2 */ +#define ROMREGION_CLASSMASK 0x000000f0 /* class of region */ + +#define ROMREGION_WIDTHMASK 0x00000300 /* native width of region, as power of 2 */ #define ROMREGION_8BIT 0x00000000 /* (non-CPU regions only) */ -#define ROMREGION_16BIT 0x00000001 -#define ROMREGION_32BIT 0x00000002 -#define ROMREGION_64BIT 0x00000003 +#define ROMREGION_16BIT 0x00000100 +#define ROMREGION_32BIT 0x00000200 +#define ROMREGION_64BIT 0x00000300 -#define ROMREGION_ENDIANMASK 0x00000004 /* endianness of the region */ +#define ROMREGION_ENDIANMASK 0x00000400 /* endianness of the region */ #define ROMREGION_LE 0x00000000 /* (non-CPU regions only) */ -#define ROMREGION_BE 0x00000004 +#define ROMREGION_BE 0x00000400 -#define ROMREGION_INVERTMASK 0x00000008 /* invert the bits of the region */ +#define ROMREGION_INVERTMASK 0x00000800 /* invert the bits of the region */ #define ROMREGION_NOINVERT 0x00000000 -#define ROMREGION_INVERT 0x00000008 +#define ROMREGION_INVERT 0x00000800 -#define ROMREGION_DISPOSEMASK 0x00000010 /* dispose of the region after init */ +#define ROMREGION_DISPOSEMASK 0x00001000 /* dispose of the region after init */ #define ROMREGION_NODISPOSE 0x00000000 -#define ROMREGION_DISPOSE 0x00000010 - -#define ROMREGION_LOADUPPERMASK 0x00000040 /* load into the upper part of CPU space */ -#define ROMREGION_LOADLOWER 0x00000000 /* (CPU regions only) */ -#define ROMREGION_LOADUPPER 0x00000040 +#define ROMREGION_DISPOSE 0x00001000 -#define ROMREGION_ERASEMASK 0x00000080 /* erase the region before loading */ +#define ROMREGION_ERASEMASK 0x00002000 /* erase the region before loading */ #define ROMREGION_NOERASE 0x00000000 -#define ROMREGION_ERASE 0x00000080 +#define ROMREGION_ERASE 0x00002000 -#define ROMREGION_ERASEVALMASK 0x0000ff00 /* value to erase the region to */ -#define ROMREGION_ERASEVAL(x) ((((x) & 0xff) << 8) | ROMREGION_ERASE) +#define ROMREGION_DATATYPEMASK 0x00004000 /* type of region (ROM versus disk) */ +#define ROMREGION_DATATYPEROM 0x00000000 +#define ROMREGION_DATATYPEDISK 0x00004000 + +#define ROMREGION_ERASEVALMASK 0x00ff0000 /* value to erase the region to */ +#define ROMREGION_ERASEVAL(x) ((((x) & 0xff) << 16) | ROMREGION_ERASE) #define ROMREGION_ERASE00 ROMREGION_ERASEVAL(0) #define ROMREGION_ERASEFF ROMREGION_ERASEVAL(0xff) -#define ROMREGION_DATATYPEMASK 0x00010000 /* inherit all flags from previous definition */ -#define ROMREGION_DATATYPEROM 0x00000000 -#define ROMREGION_DATATYPEDISK 0x00010000 - /* ----- per-ROM constants ----- */ -#define DISK_READONLYMASK 0x00000400 /* is the disk read-only? */ +#define DISK_READONLYMASK 0x00000010 /* is the disk read-only? */ #define DISK_READWRITE 0x00000000 -#define DISK_READONLY 0x00000400 +#define DISK_READONLY 0x00000010 -#define ROM_OPTIONALMASK 0x00000800 /* optional - won't hurt if it's not there */ +#define ROM_OPTIONALMASK 0x00000020 /* optional - won't hurt if it's not there */ #define ROM_REQUIRED 0x00000000 -#define ROM_OPTIONAL 0x00000800 +#define ROM_OPTIONAL 0x00000020 + +#define ROM_REVERSEMASK 0x00000040 /* reverse the byte order within a group */ +#define ROM_NOREVERSE 0x00000000 +#define ROM_REVERSE 0x00000040 + +#define ROM_INHERITFLAGSMASK 0x00000080 /* inherit all flags from previous definition */ +#define ROM_INHERITFLAGS 0x00000080 -#define ROM_GROUPMASK 0x0000f000 /* load data in groups of this size + 1 */ -#define ROM_GROUPSIZE(n) ((((n) - 1) & 15) << 12) +#define ROM_GROUPMASK 0x00000f00 /* load data in groups of this size + 1 */ +#define ROM_GROUPSIZE(n) ((((n) - 1) & 15) << 8) #define ROM_GROUPBYTE ROM_GROUPSIZE(1) #define ROM_GROUPWORD ROM_GROUPSIZE(2) #define ROM_GROUPDWORD ROM_GROUPSIZE(4) -#define ROM_SKIPMASK 0x000f0000 /* skip this many bytes after each group */ -#define ROM_SKIP(n) (((n) & 15) << 16) +#define ROM_SKIPMASK 0x0000f000 /* skip this many bytes after each group */ +#define ROM_SKIP(n) (((n) & 15) << 12) #define ROM_NOSKIP ROM_SKIP(0) -#define ROM_REVERSEMASK 0x00100000 /* reverse the byte order within a group */ -#define ROM_NOREVERSE 0x00000000 -#define ROM_REVERSE 0x00100000 - -#define ROM_BITWIDTHMASK 0x00e00000 /* width of data in bits */ -#define ROM_BITWIDTH(n) (((n) & 7) << 21) +#define ROM_BITWIDTHMASK 0x000f0000 /* width of data in bits */ +#define ROM_BITWIDTH(n) (((n) & 15) << 16) #define ROM_NIBBLE ROM_BITWIDTH(4) #define ROM_FULLBYTE ROM_BITWIDTH(8) -#define ROM_BITSHIFTMASK 0x07000000 /* left-shift count for the bits */ -#define ROM_BITSHIFT(n) (((n) & 7) << 24) +#define ROM_BITSHIFTMASK 0x00f00000 /* left-shift count for the bits */ +#define ROM_BITSHIFT(n) (((n) & 15) << 20) #define ROM_NOSHIFT ROM_BITSHIFT(0) #define ROM_SHIFT_NIBBLE_LO ROM_BITSHIFT(0) #define ROM_SHIFT_NIBBLE_HI ROM_BITSHIFT(4) -#define ROM_INHERITFLAGSMASK 0x08000000 /* inherit all flags from previous definition */ -#define ROM_INHERITFLAGS 0x08000000 - -#define ROM_BIOSFLAGSMASK 0xf0000000 /* only loaded if value matches global bios value */ -#define ROM_BIOS(n) (((n) & 15) << 28) +#define ROM_BIOSFLAGSMASK 0xff000000 /* only loaded if value matches global bios value */ +#define ROM_BIOS(n) (((n) & 255) << 24) #define ROM_INHERITEDFLAGS (ROM_GROUPMASK | ROM_SKIPMASK | ROM_REVERSEMASK | ROM_BITWIDTHMASK | ROM_BITSHIFTMASK | ROM_BIOSFLAGSMASK) @@ -127,10 +127,10 @@ typedef struct _rom_entry rom_entry; struct _rom_entry { const char * _name; /* name of the file to load */ + const char * _hashdata; /* hashing informations (checksums) */ UINT32 _offset; /* offset to load it to */ UINT32 _length; /* length of the file */ UINT32 _flags; /* flags */ - const char * _hashdata; /* hashing informations (checksums) */ }; @@ -159,41 +159,31 @@ struct _rom_load_data ***************************************************************************/ /* ----- per-entry macros ----- */ -#define ROMENTRY_REGION ((const char *)ROMENTRYTYPE_REGION) -#define ROMENTRY_END ((const char *)ROMENTRYTYPE_END) -#define ROMENTRY_RELOAD ((const char *)ROMENTRYTYPE_RELOAD) -#define ROMENTRY_CONTINUE ((const char *)ROMENTRYTYPE_CONTINUE) -#define ROMENTRY_FILL ((const char *)ROMENTRYTYPE_FILL) -#define ROMENTRY_COPY ((const char *)ROMENTRYTYPE_COPY) -#define ROMENTRY_CARTRIDGE ((const char *)ROMENTRYTYPE_CARTRIDGE) -#define ROMENTRY_IGNORE ((const char *)ROMENTRYTYPE_IGNORE) -#define ROMENTRY_SYSTEM_BIOS ((const char *)ROMENTRYTYPE_SYSTEM_BIOS) - -#define ROMENTRY_GETTYPE(r) ((FPTR)(r)->_name) -#define ROMENTRY_ISSPECIAL(r) (ROMENTRY_GETTYPE(r) < ROMENTRYTYPE_COUNT) -#define ROMENTRY_ISFILE(r) (!ROMENTRY_ISSPECIAL(r)) -#define ROMENTRY_ISREGION(r) ((r)->_name == ROMENTRY_REGION) -#define ROMENTRY_ISEND(r) ((r)->_name == ROMENTRY_END) -#define ROMENTRY_ISRELOAD(r) ((r)->_name == ROMENTRY_RELOAD) -#define ROMENTRY_ISCONTINUE(r) ((r)->_name == ROMENTRY_CONTINUE) -#define ROMENTRY_ISFILL(r) ((r)->_name == ROMENTRY_FILL) -#define ROMENTRY_ISCOPY(r) ((r)->_name == ROMENTRY_COPY) -#define ROMENTRY_ISIGNORE(r) ((r)->_name == ROMENTRY_IGNORE) -#define ROMENTRY_ISSYSTEM_BIOS(r) ((r)->_name == ROMENTRY_SYSTEM_BIOS) +#define ROMENTRY_GETTYPE(r) ((r)->_flags & ROMENTRY_TYPEMASK) +#define ROMENTRY_ISSPECIAL(r) (ROMENTRY_GETTYPE(r) != ROMENTRYTYPE_ROM) +#define ROMENTRY_ISFILE(r) (ROMENTRY_GETTYPE(r) == ROMENTRYTYPE_ROM) +#define ROMENTRY_ISREGION(r) (ROMENTRY_GETTYPE(r) == ROMENTRYTYPE_REGION) +#define ROMENTRY_ISEND(r) (ROMENTRY_GETTYPE(r) == ROMENTRYTYPE_END) +#define ROMENTRY_ISRELOAD(r) (ROMENTRY_GETTYPE(r) == ROMENTRYTYPE_RELOAD) +#define ROMENTRY_ISCONTINUE(r) (ROMENTRY_GETTYPE(r) == ROMENTRYTYPE_CONTINUE) +#define ROMENTRY_ISFILL(r) (ROMENTRY_GETTYPE(r) == ROMENTRYTYPE_FILL) +#define ROMENTRY_ISCOPY(r) (ROMENTRY_GETTYPE(r) == ROMENTRYTYPE_COPY) +#define ROMENTRY_ISIGNORE(r) (ROMENTRY_GETTYPE(r) == ROMENTRYTYPE_IGNORE) +#define ROMENTRY_ISSYSTEM_BIOS(r) (ROMENTRY_GETTYPE(r) == ROMENTRYTYPE_SYSTEM_BIOS) #define ROMENTRY_ISREGIONEND(r) (ROMENTRY_ISREGION(r) || ROMENTRY_ISEND(r)) /* ----- per-region macros ----- */ -#define ROMREGION_GETTYPE(r) ((FPTR)(r)->_hashdata) +#define ROMREGION_GETTAG(r) ((r)->_name) #define ROMREGION_GETLENGTH(r) ((r)->_length) #define ROMREGION_GETFLAGS(r) ((r)->_flags) -#define ROMREGION_GETWIDTH(r) (8 << (ROMREGION_GETFLAGS(r) & ROMREGION_WIDTHMASK)) +#define ROMREGION_GETCLASS(r) ((ROMREGION_GETFLAGS(r) & ROMREGION_CLASSMASK) >> 4) +#define ROMREGION_GETWIDTH(r) (8 << ((ROMREGION_GETFLAGS(r) & ROMREGION_WIDTHMASK) >> 8)) #define ROMREGION_ISLITTLEENDIAN(r) ((ROMREGION_GETFLAGS(r) & ROMREGION_ENDIANMASK) == ROMREGION_LE) #define ROMREGION_ISBIGENDIAN(r) ((ROMREGION_GETFLAGS(r) & ROMREGION_ENDIANMASK) == ROMREGION_BE) #define ROMREGION_ISINVERTED(r) ((ROMREGION_GETFLAGS(r) & ROMREGION_INVERTMASK) == ROMREGION_INVERT) #define ROMREGION_ISDISPOSE(r) ((ROMREGION_GETFLAGS(r) & ROMREGION_DISPOSEMASK) == ROMREGION_DISPOSE) -#define ROMREGION_ISLOADUPPER(r) ((ROMREGION_GETFLAGS(r) & ROMREGION_LOADUPPERMASK) == ROMREGION_LOADUPPER) #define ROMREGION_ISERASE(r) ((ROMREGION_GETFLAGS(r) & ROMREGION_ERASEMASK) == ROMREGION_ERASE) -#define ROMREGION_GETERASEVAL(r) ((ROMREGION_GETFLAGS(r) & ROMREGION_ERASEVALMASK) >> 8) +#define ROMREGION_GETERASEVAL(r) ((ROMREGION_GETFLAGS(r) & ROMREGION_ERASEVALMASK) >> 16) #define ROMREGION_GETDATATYPE(r) (ROMREGION_GETFLAGS(r) & ROMREGION_DATATYPEMASK) #define ROMREGION_ISROMDATA(r) (ROMREGION_GETDATATYPE(r) == ROMREGION_DATATYPEROM) #define ROMREGION_ISDISKDATA(r) (ROMREGION_GETDATATYPE(r) == ROMREGION_DATATYPEDISK) @@ -207,13 +197,13 @@ struct _rom_load_data #define ROM_GETFLAGS(r) ((r)->_flags) #define ROM_GETHASHDATA(r) ((r)->_hashdata) #define ROM_ISOPTIONAL(r) ((ROM_GETFLAGS(r) & ROM_OPTIONALMASK) == ROM_OPTIONAL) -#define ROM_GETGROUPSIZE(r) (((ROM_GETFLAGS(r) & ROM_GROUPMASK) >> 12) + 1) -#define ROM_GETSKIPCOUNT(r) ((ROM_GETFLAGS(r) & ROM_SKIPMASK) >> 16) +#define ROM_GETGROUPSIZE(r) (((ROM_GETFLAGS(r) & ROM_GROUPMASK) >> 8) + 1) +#define ROM_GETSKIPCOUNT(r) ((ROM_GETFLAGS(r) & ROM_SKIPMASK) >> 12) #define ROM_ISREVERSED(r) ((ROM_GETFLAGS(r) & ROM_REVERSEMASK) == ROM_REVERSE) -#define ROM_GETBITWIDTH(r) (((ROM_GETFLAGS(r) & ROM_BITWIDTHMASK) >> 21) + 8 * ((ROM_GETFLAGS(r) & ROM_BITWIDTHMASK) == 0)) -#define ROM_GETBITSHIFT(r) ((ROM_GETFLAGS(r) & ROM_BITSHIFTMASK) >> 24) +#define ROM_GETBITWIDTH(r) (((ROM_GETFLAGS(r) & ROM_BITWIDTHMASK) >> 16) + 8 * ((ROM_GETFLAGS(r) & ROM_BITWIDTHMASK) == 0)) +#define ROM_GETBITSHIFT(r) ((ROM_GETFLAGS(r) & ROM_BITSHIFTMASK) >> 20) #define ROM_INHERITSFLAGS(r) ((ROM_GETFLAGS(r) & ROM_INHERITFLAGSMASK) == ROM_INHERITFLAGS) -#define ROM_GETBIOSFLAGS(r) ((ROM_GETFLAGS(r) & ROM_BIOSFLAGSMASK) >> 28) +#define ROM_GETBIOSFLAGS(r) ((ROM_GETFLAGS(r) & ROM_BIOSFLAGSMASK) >> 24) #define ROM_NOGOODDUMP(r) (hash_data_has_info((r)->_hashdata, HASH_INFO_NO_DUMP)) @@ -224,29 +214,23 @@ struct _rom_load_data /* ----- start/stop macros ----- */ #define ROM_START(name) static const rom_entry rom_##name[] = { -#define ROM_END { ROMENTRY_END, 0, 0, 0, NULL } }; +#define ROM_END { NULL, NULL, 0, 0, ROMENTRYTYPE_END } }; /* ----- ROM region macros ----- */ -#define ROM_REGION(length,type,flags) { ROMENTRY_REGION, 0, length, flags, (const char*)type }, -#define ROM_REGION16_LE(length,type,flags) ROM_REGION(length, type, (flags) | ROMREGION_16BIT | ROMREGION_LE) -#define ROM_REGION16_BE(length,type,flags) ROM_REGION(length, type, (flags) | ROMREGION_16BIT | ROMREGION_BE) -#define ROM_REGION32_LE(length,type,flags) ROM_REGION(length, type, (flags) | ROMREGION_32BIT | ROMREGION_LE) -#define ROM_REGION32_BE(length,type,flags) ROM_REGION(length, type, (flags) | ROMREGION_32BIT | ROMREGION_BE) -#define ROM_REGION64_LE(length,type,flags) ROM_REGION(length, type, (flags) | ROMREGION_64BIT | ROMREGION_LE) -#define ROM_REGION64_BE(length,type,flags) ROM_REGION(length, type, (flags) | ROMREGION_64BIT | ROMREGION_BE) +#define ROM_REGION(length,rclass,rtag,flags) { rtag, NULL, 0, length, ROMENTRYTYPE_REGION | ((rclass) << 4) | (flags) }, +#define ROM_REGION16_LE(length,rclass,rtag,flags) ROM_REGION(length, rclass, rtag, (flags) | ROMREGION_16BIT | ROMREGION_LE) +#define ROM_REGION16_BE(length,rclass,rtag,flags) ROM_REGION(length, rclass, rtag, (flags) | ROMREGION_16BIT | ROMREGION_BE) +#define ROM_REGION32_LE(length,rclass,rtag,flags) ROM_REGION(length, rclass, rtag, (flags) | ROMREGION_32BIT | ROMREGION_LE) +#define ROM_REGION32_BE(length,rclass,rtag,flags) ROM_REGION(length, rclass, rtag, (flags) | ROMREGION_32BIT | ROMREGION_BE) +#define ROM_REGION64_LE(length,rclass,rtag,flags) ROM_REGION(length, rclass, rtag, (flags) | ROMREGION_64BIT | ROMREGION_LE) +#define ROM_REGION64_BE(length,rclass,rtag,flags) ROM_REGION(length, rclass, rtag, (flags) | ROMREGION_64BIT | ROMREGION_BE) /* ----- core ROM loading macros ----- */ -#define ROMMD5_LOAD(name,offset,length,hash,flags) { name, offset, length, flags, hash }, -#define ROMX_LOAD(name,offset,length,hash,flags) { name, offset, length, flags, hash }, +#define ROMX_LOAD(name,offset,length,hash,flags) { name, hash, offset, length, ROMENTRYTYPE_ROM | (flags) }, #define ROM_LOAD(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, 0) #define ROM_LOAD_OPTIONAL(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_OPTIONAL) -#define ROM_CONTINUE(offset,length) ROMX_LOAD(ROMENTRY_CONTINUE, offset, length, 0, ROM_INHERITFLAGS) -#define ROM_RELOAD(offset,length) ROMX_LOAD(ROMENTRY_RELOAD, offset, length, 0, ROM_INHERITFLAGS) -#define ROM_FILL(offset,length,value) ROM_LOAD(ROMENTRY_FILL, offset, length, (const char*)value) -#define ROM_COPY(rgn,srcoffset,offset,length) ROMX_LOAD(ROMENTRY_COPY, offset, length, (const char*)srcoffset, (rgn) << 24) -#define ROM_IGNORE(length) ROMX_LOAD(ROMENTRY_IGNORE, 0, length, 0, ROM_INHERITFLAGS) /* ----- specialized loading macros ----- */ @@ -261,13 +245,22 @@ struct _rom_load_data #define ROM_LOAD32_DWORD(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_GROUPDWORD) +/* ----- additional ROM-related macros ----- */ +#define ROM_CONTINUE(offset,length) { NULL, NULL, offset, length, ROMENTRYTYPE_CONTINUE | ROM_INHERITFLAGS }, +#define ROM_RELOAD(offset,length) { NULL, NULL, offset, length, ROMENTRYTYPE_RELOAD | ROM_INHERITFLAGS }, +#define ROM_IGNORE(length) { NULL, NULL, 0, length, ROMENTRYTYPE_IGNORE | ROM_INHERITFLAGS }, +#define ROM_FILL(offset,length,value) { NULL, (const char *)value, offset, length, ROMENTRYTYPE_FILL }, +#define ROM_COPY(rclass,rtag,srcoffs,offset,length) { rtag, (const char *)srcoffs, offset, length, ROMENTRYTYPE_COPY | ((rclass) << 4) }, + + /* ----- system BIOS macros ----- */ -#define ROM_SYSTEM_BIOS(value,name,description) ROMX_LOAD(ROMENTRY_SYSTEM_BIOS, 0, 0, name "\0" description, ROM_BIOS(value+1)) +#define ROM_SYSTEM_BIOS(value,name,description) { name, description, 0, 0, ROMENTRYTYPE_SYSTEM_BIOS | ROM_BIOS(value+1) }, + /* ----- disk loading macros ----- */ -#define DISK_REGION(type) ROM_REGION(1, type, ROMREGION_DATATYPEDISK) -#define DISK_IMAGE(name,idx,hash) ROMMD5_LOAD(name, idx, 0, hash, DISK_READWRITE) -#define DISK_IMAGE_READONLY(name,idx,hash) ROMMD5_LOAD(name, idx, 0, hash, DISK_READONLY) +#define DISK_REGION(type, tag) ROM_REGION(1, type, tag, ROMREGION_DATATYPEDISK) +#define DISK_IMAGE(name,idx,hash) ROMX_LOAD(name, idx, 0, hash, DISK_READWRITE) +#define DISK_IMAGE_READONLY(name,idx,hash) ROMX_LOAD(name, idx, 0, hash, DISK_READONLY) /* ----- hash macros ----- */ diff --git a/src/emu/sndintrf.c b/src/emu/sndintrf.c index d2ec99f3148..2a28c74fcfb 100644 --- a/src/emu/sndintrf.c +++ b/src/emu/sndintrf.c @@ -40,7 +40,7 @@ struct _sound_interface /* table of core functions */ void (*get_info)(void *token, UINT32 state, sndinfo *info); void (*set_info)(void *token, UINT32 state, sndinfo *info); - void * (*start)(int index, int clock, const void *config); + void * (*start)(const char *tag, int index, int clock, const void *config); void (*stop)(void *token); void (*reset)(void *token); }; @@ -52,9 +52,10 @@ struct _sndintrf_data sound_interface intf; /* copy of the interface data */ sound_type sndtype; /* type index of this sound chip */ sound_type aliastype; /* aliased type index of this sound chip */ + void * token; /* dynamically allocated token data */ + const char * tag; /* tag this sound chip */ int index; /* index of this sound chip */ int clock; /* clock for this sound chip */ - void * token; /* dynamically allocated token data */ }; @@ -582,13 +583,14 @@ void sndintrf_init(running_machine *machine) particular sndnum -------------------------------------------------*/ -int sndintrf_init_sound(int sndnum, sound_type sndtype, int clock, const void *config) +int sndintrf_init_sound(int sndnum, const char *tag, sound_type sndtype, int clock, const void *config) { sndintrf_data *info = &sound[sndnum]; int index; /* fill in the type and interface */ info->intf = sndintrf[sndtype]; + info->tag = tag; info->sndtype = sndtype; info->aliastype = sndtype_get_info_int(sndtype, SNDINFO_INT_ALIAS); if (info->aliastype == 0) @@ -607,7 +609,7 @@ int sndintrf_init_sound(int sndnum, sound_type sndtype, int clock, const void *c /* start the chip, tagging all its streams */ current_sound_start = &sound[sndnum]; - info->token = (*info->intf.start)(index, clock, config); + info->token = (*info->intf.start)(info->tag, index, clock, config); current_sound_start = NULL; VPRINTF((" token = %p\n", info->token)); @@ -987,7 +989,7 @@ const char *sndtype_get_info_string(sound_type sndtype, UINT32 state) DUMMY INTERFACES ***************************************************************************/ -static void *dummy_sound_start(int index, int clock, const void *config) +static void *dummy_sound_start(const char *tag, int index, int clock, const void *config) { logerror("Warning: starting a dummy sound core -- you are missing a hookup in sndintrf.c!\n"); return auto_malloc(1); diff --git a/src/emu/sndintrf.h b/src/emu/sndintrf.h index 59a63df2ad0..35c047fdb50 100644 --- a/src/emu/sndintrf.h +++ b/src/emu/sndintrf.h @@ -194,7 +194,7 @@ union _sndinfo const char *s; /* generic strings */ void (*set_info)(void *token, UINT32 state, sndinfo *info); - void * (*start)(int index, int clock, const void *config);/* SNDINFO_PTR_START */ + void * (*start)(const char *tag, int index, int clock, const void *config);/* SNDINFO_PTR_START */ void (*stop)(void *token); /* SNDINFO_PTR_STOP */ void (*reset)(void *token); /* SNDINFO_PTR_RESET */ }; @@ -284,7 +284,7 @@ const char *sndtype_get_info_string(sound_type sndtype, UINT32 state); /* Initialization/Tear down */ void sndintrf_init(running_machine *machine); -int sndintrf_init_sound(int sndnum, sound_type sndtype, int clock, const void *config); +int sndintrf_init_sound(int sndnum, const char *tag, sound_type sndtype, int clock, const void *config); void sndintrf_exit_sound(int sndnum); void sndintrf_register_token(void *token); diff --git a/src/emu/sound.c b/src/emu/sound.c index 9299af09fc8..f8e8b37ab2d 100644 --- a/src/emu/sound.c +++ b/src/emu/sound.c @@ -295,7 +295,7 @@ static void start_sound_chips(void) VPRINTF(("sndnum = %d -- sound_type = %d\n", sndnum, msound->type)); num_regs = state_save_get_reg_count(); streams_set_tag(Machine, info); - if (sndintrf_init_sound(sndnum, msound->type, msound->clock, msound->config) != 0) + if (sndintrf_init_sound(sndnum, msound->tag, msound->type, msound->clock, msound->config) != 0) fatalerror("Sound chip #%d (%s) failed to initialize!", sndnum, sndnum_name(sndnum)); /* if no state registered for saving, we can't save */ diff --git a/src/emu/sound/2151intf.c b/src/emu/sound/2151intf.c index 5c0ea2414ee..ff747cccacc 100644 --- a/src/emu/sound/2151intf.c +++ b/src/emu/sound/2151intf.c @@ -37,7 +37,7 @@ static STATE_POSTLOAD( ym2151_postload ) } -static void *ym2151_start(int sndindex, int clock, const void *config) +static void *ym2151_start(const char *tag, int sndindex, int clock, const void *config) { static const struct YM2151interface dummy = { 0 }; struct ym2151_info *info; diff --git a/src/emu/sound/2203intf.c b/src/emu/sound/2203intf.c index c281499c3e7..08eb1fb8018 100644 --- a/src/emu/sound/2203intf.c +++ b/src/emu/sound/2203intf.c @@ -105,7 +105,7 @@ static STATE_POSTLOAD( ym2203_postload ) } -static void *ym2203_start(int sndindex, int clock, const void *config) +static void *ym2203_start(const char *tag, int sndindex, int clock, const void *config) { static const struct YM2203interface generic_2203 = { diff --git a/src/emu/sound/2413intf.c b/src/emu/sound/2413intf.c index b7368998a00..cadd9d94e7e 100644 --- a/src/emu/sound/2413intf.c +++ b/src/emu/sound/2413intf.c @@ -48,7 +48,7 @@ static void _stream_update(void *param, int interval) stream_update(info->stream); } -static void *ym2413_start(int sndindex, int clock, const void *config) +static void *ym2413_start(const char *tag, int sndindex, int clock, const void *config) { int rate = clock/72; struct ym2413_info *info; diff --git a/src/emu/sound/2608intf.c b/src/emu/sound/2608intf.c index 19463695374..014bd59a820 100644 --- a/src/emu/sound/2608intf.c +++ b/src/emu/sound/2608intf.c @@ -118,7 +118,7 @@ static STATE_POSTLOAD( ym2608_postload ) } -static void *ym2608_start(int sndindex, int clock, const void *config) +static void *ym2608_start(const char *tag, int sndindex, int clock, const void *config) { static const struct YM2608interface generic_2608 = { @@ -127,8 +127,7 @@ static void *ym2608_start(int sndindex, int clock, const void *config) AY8910_DEFAULT_LOADS, NULL, NULL, NULL, NULL }, - NULL, - 0, + NULL }; const struct YM2608interface *intf = config ? config : &generic_2608; int rate = clock/72; @@ -152,8 +151,8 @@ static void *ym2608_start(int sndindex, int clock, const void *config) /* stream system initialize */ info->stream = stream_create(0,2,rate,info,ym2608_stream_update); /* setup adpcm buffers */ - pcmbufa = (void *)(memory_region(Machine, info->intf->pcmrom)); - pcmsizea = memory_region_length(Machine, info->intf->pcmrom); + pcmbufa = (void *)(memory_region(Machine, RGNCLASS_SOUND, tag)); + pcmsizea = memory_region_length(Machine, RGNCLASS_SOUND, tag); /* initialize YM2608 */ info->chip = YM2608Init(info,sndindex,clock,rate, diff --git a/src/emu/sound/2608intf.h b/src/emu/sound/2608intf.h index 2da44d104da..d447979987c 100644 --- a/src/emu/sound/2608intf.h +++ b/src/emu/sound/2608intf.h @@ -8,7 +8,6 @@ struct YM2608interface { const struct AY8910interface ay8910_intf; void ( *handler )( running_machine *machine, int irq ); /* IRQ handler for the YM2608 */ - int pcmrom; /* Delta-T memory region ram/rom */ }; /************************************************/ diff --git a/src/emu/sound/2610intf.c b/src/emu/sound/2610intf.c index 072e9a47524..9773b036be3 100644 --- a/src/emu/sound/2610intf.c +++ b/src/emu/sound/2610intf.c @@ -120,7 +120,7 @@ static STATE_POSTLOAD( ym2610_postload ) } -static void *ym2610_start(int sndindex, int clock, const void *config) +static void *ym2610_start(const char *tag, int sndindex, int clock, const void *config) { static const struct YM2610interface generic_2610 = { 0 }; static const struct AY8910interface generic_ay8910 = @@ -134,6 +134,7 @@ static void *ym2610_start(int sndindex, int clock, const void *config) void *pcmbufa,*pcmbufb; int pcmsizea,pcmsizeb; struct ym2610_info *info; + astring *name = astring_alloc(); chip_type = SOUND_YM2610; @@ -151,10 +152,17 @@ static void *ym2610_start(int sndindex, int clock, const void *config) /* stream system initialize */ info->stream = stream_create(0,2,rate,info,ym2610_stream_update); /* setup adpcm buffers */ - pcmbufa = (void *)(memory_region(Machine, info->intf->pcmroma)); - pcmsizea = memory_region_length(Machine, info->intf->pcmroma); - pcmbufb = (void *)(memory_region(Machine, info->intf->pcmromb)); - pcmsizeb = memory_region_length(Machine, info->intf->pcmromb); + pcmbufa = (void *)(memory_region(Machine, RGNCLASS_SOUND, tag)); + pcmsizea = memory_region_length(Machine, RGNCLASS_SOUND, tag); + astring_printf(name, "%s.deltat", tag); + pcmbufb = (void *)(memory_region(Machine, RGNCLASS_SOUND, astring_c(name))); + pcmsizeb = memory_region_length(Machine, RGNCLASS_SOUND, astring_c(name)); + astring_free(name); + if (pcmbufb == NULL || pcmsizeb == 0) + { + pcmbufb = pcmbufa; + pcmsizeb = pcmsizea; + } /**** initialize YM2610 ****/ info->chip = YM2610Init(info,sndindex,clock,rate, @@ -178,7 +186,7 @@ static void ym2610b_stream_update(void *param, stream_sample_t **inputs, stream_ YM2610BUpdateOne(info->chip, buffers, length); } -static void *ym2610b_start(int sndindex, int clock, const void *config) +static void *ym2610b_start(const char *tag, int sndindex, int clock, const void *config) { static const struct YM2610interface generic_2610 = { 0 }; static const struct AY8910interface generic_ay8910 = @@ -192,6 +200,7 @@ static void *ym2610b_start(int sndindex, int clock, const void *config) void *pcmbufa,*pcmbufb; int pcmsizea,pcmsizeb; struct ym2610_info *info; + astring *name = astring_alloc(); chip_type = SOUND_YM2610B; @@ -209,10 +218,17 @@ static void *ym2610b_start(int sndindex, int clock, const void *config) /* stream system initialize */ info->stream = stream_create(0,2,rate,info,ym2610b_stream_update); /* setup adpcm buffers */ - pcmbufa = (void *)(memory_region(Machine, info->intf->pcmroma)); - pcmsizea = memory_region_length(Machine, info->intf->pcmroma); - pcmbufb = (void *)(memory_region(Machine, info->intf->pcmromb)); - pcmsizeb = memory_region_length(Machine, info->intf->pcmromb); + pcmbufa = (void *)(memory_region(Machine, RGNCLASS_SOUND, tag)); + pcmsizea = memory_region_length(Machine, RGNCLASS_SOUND, tag); + astring_printf(name, "%s.deltat", tag); + pcmbufb = (void *)(memory_region(Machine, RGNCLASS_SOUND, astring_c(name))); + pcmsizeb = memory_region_length(Machine, RGNCLASS_SOUND, astring_c(name)); + astring_free(name); + if (pcmbufb == NULL || pcmsizeb == 0) + { + pcmbufb = pcmbufa; + pcmsizeb = pcmsizea; + } /**** initialize YM2610 ****/ info->chip = YM2610Init(info,sndindex,clock,rate, diff --git a/src/emu/sound/2610intf.h b/src/emu/sound/2610intf.h index 04a7a4ab0b9..d5790001cb0 100644 --- a/src/emu/sound/2610intf.h +++ b/src/emu/sound/2610intf.h @@ -6,8 +6,6 @@ struct YM2610interface { void ( *handler )( running_machine *machine, int irq ); /* IRQ handler for the YM2610 */ - int pcmromb; /* Delta-T rom region */ - int pcmroma; /* ADPCM rom region */ }; /************************************************/ diff --git a/src/emu/sound/2612intf.c b/src/emu/sound/2612intf.c index a77a5d79da0..6beb69f1e40 100644 --- a/src/emu/sound/2612intf.c +++ b/src/emu/sound/2612intf.c @@ -87,7 +87,7 @@ static STATE_POSTLOAD( ym2612_postload ) } -static void *ym2612_start(int sndindex, int clock, const void *config) +static void *ym2612_start(const char *tag, int sndindex, int clock, const void *config) { static const struct YM2612interface dummy = { 0 }; struct ym2612_info *info; diff --git a/src/emu/sound/262intf.c b/src/emu/sound/262intf.c index 01e18ed9f56..85f842c999a 100644 --- a/src/emu/sound/262intf.c +++ b/src/emu/sound/262intf.c @@ -67,7 +67,7 @@ static void _stream_update(void *param, int interval) } -static void *ymf262_start(int sndindex, int clock, const void *config) +static void *ymf262_start(const char *tag, int sndindex, int clock, const void *config) { static const struct YMF262interface dummy = { 0 }; struct ymf262_info *info; diff --git a/src/emu/sound/3812intf.c b/src/emu/sound/3812intf.c index ba17b8eb734..0a2c1898a4f 100644 --- a/src/emu/sound/3812intf.c +++ b/src/emu/sound/3812intf.c @@ -79,7 +79,7 @@ static void _stream_update_3812(void * param, int interval) } -static void *ym3812_start(int sndindex, int clock, const void *config) +static void *ym3812_start(const char *tag, int sndindex, int clock, const void *config) { static const struct YM3812interface dummy = { 0 }; struct ym3812_info *info; @@ -248,7 +248,7 @@ static void _stream_update_3526(void *param, int interval) } -static void *ym3526_start(int sndindex, int clock, const void *config) +static void *ym3526_start(const char *tag, int sndindex, int clock, const void *config) { static const struct YM3526interface dummy = { 0 }; struct ym3526_info *info; @@ -443,7 +443,7 @@ static void _stream_update_8950(void *param, int interval) } -static void *y8950_start(int sndindex, int clock, const void *config) +static void *y8950_start(const char *tag, int sndindex, int clock, const void *config) { static const struct Y8950interface dummy = { 0 }; struct y8950_info *info; @@ -462,8 +462,8 @@ static void *y8950_start(int sndindex, int clock, const void *config) /* ADPCM ROM data */ Y8950SetDeltaTMemory(info->chip, - (void *)(memory_region(Machine, info->intf->rom_region)), - memory_region_length(Machine, info->intf->rom_region) ); + (void *)(memory_region(Machine, RGNCLASS_SOUND, tag)), + memory_region_length(Machine, RGNCLASS_SOUND, tag) ); info->stream = stream_create(0,1,rate,info,y8950_stream_update); diff --git a/src/emu/sound/3812intf.h b/src/emu/sound/3812intf.h index 6c6f0045d6e..2e0c381a96a 100644 --- a/src/emu/sound/3812intf.h +++ b/src/emu/sound/3812intf.h @@ -13,8 +13,6 @@ struct Y8950interface { void (*handler)(running_machine *machine, int linestate); - int rom_region; /* delta-T ADPCM ROM/RAM region */ - read8_machine_func keyboardread; write8_machine_func keyboardwrite; read8_machine_func portread; diff --git a/src/emu/sound/5110intf.c b/src/emu/sound/5110intf.c index e5e51f0019a..db46ab3c5bb 100644 --- a/src/emu/sound/5110intf.c +++ b/src/emu/sound/5110intf.c @@ -26,6 +26,7 @@ struct tms5110_info { const struct TMS5110interface *intf; + const char *tag; sound_stream *stream; void *chip; INT32 speech_rom_bitnum; @@ -38,7 +39,7 @@ static void tms5110_update(void *param, stream_sample_t **inputs, stream_sample_ static int speech_rom_read_bit(void) { struct tms5110_info *info = sndti_token(SOUND_TMS5110, 0); - const UINT8 *table = memory_region(Machine, info->intf->rom_region); + const UINT8 *table = memory_region(Machine, RGNCLASS_SOUND, info->tag); int r; @@ -65,14 +66,15 @@ static void speech_rom_set_addr(int addr) ******************************************************************************/ -static void *tms5110_start(int sndindex, int clock, const void *config) +static void *tms5110_start(const char *tag, int sndindex, int clock, const void *config) { - static const struct TMS5110interface dummy = { -1 }; + static const struct TMS5110interface dummy = { 0 }; struct tms5110_info *info; info = auto_malloc(sizeof(*info)); memset(info, 0, sizeof(*info)); info->intf = config ? config : &dummy; + info->tag = tag; info->chip = tms5110_create(sndindex, TMS5110_IS_5110A); if (!info->chip) @@ -82,7 +84,7 @@ static void *tms5110_start(int sndindex, int clock, const void *config) /* initialize a stream */ info->stream = stream_create(0, 1, clock / 80, info, tms5110_update); - if (info->intf->rom_region == -1 ) + if (memory_region(Machine, RGNCLASS_SOUND, tag) == NULL) { if (info->intf->M0_callback==NULL) { @@ -105,44 +107,44 @@ static void *tms5110_start(int sndindex, int clock, const void *config) return info; } -static void *tms5100_start(int sndindex, int clock, const void *config) +static void *tms5100_start(const char *tag, int sndindex, int clock, const void *config) { - struct tms5110_info *info = tms5110_start(sndindex, clock, config); + struct tms5110_info *info = tms5110_start(tag, sndindex, clock, config); tms5110_set_variant(info->chip, TMS5110_IS_5100); return info; } -static void *tms5110a_start(int sndindex, int clock, const void *config) +static void *tms5110a_start(const char *tag, int sndindex, int clock, const void *config) { - struct tms5110_info *info = tms5110_start(sndindex, clock, config); + struct tms5110_info *info = tms5110_start(tag, sndindex, clock, config); tms5110_set_variant(info->chip, TMS5110_IS_5110A); return info; } -static void *cd2801_start(int sndindex, int clock, const void *config) +static void *cd2801_start(const char *tag, int sndindex, int clock, const void *config) { - struct tms5110_info *info = tms5110_start(sndindex, clock, config); + struct tms5110_info *info = tms5110_start(tag, sndindex, clock, config); tms5110_set_variant(info->chip, TMS5110_IS_CD2801); return info; } -static void *tmc0281_start(int sndindex, int clock, const void *config) +static void *tmc0281_start(const char *tag, int sndindex, int clock, const void *config) { - struct tms5110_info *info = tms5110_start(sndindex, clock, config); + struct tms5110_info *info = tms5110_start(tag, sndindex, clock, config); tms5110_set_variant(info->chip, TMS5110_IS_TMC0281); return info; } -static void *cd2802_start(int sndindex, int clock, const void *config) +static void *cd2802_start(const char *tag, int sndindex, int clock, const void *config) { - struct tms5110_info *info = tms5110_start(sndindex, clock, config); + struct tms5110_info *info = tms5110_start(tag, sndindex, clock, config); tms5110_set_variant(info->chip, TMS5110_IS_CD2802); return info; } -static void *m58817_start(int sndindex, int clock, const void *config) +static void *m58817_start(const char *tag, int sndindex, int clock, const void *config) { - struct tms5110_info *info = tms5110_start(sndindex, clock, config); + struct tms5110_info *info = tms5110_start(tag, sndindex, clock, config); tms5110_set_variant(info->chip, TMS5110_IS_M58817); return info; } diff --git a/src/emu/sound/5110intf.h b/src/emu/sound/5110intf.h index 7a9dcfd4dd0..59873b2d56e 100644 --- a/src/emu/sound/5110intf.h +++ b/src/emu/sound/5110intf.h @@ -7,7 +7,6 @@ struct TMS5110interface { - int rom_region; /* set to -1 to specifiy callbacks below */ int (*M0_callback)(void); /* function to be called when chip requests another bit */ void (*load_address)(int addr); /* speech ROM load address callback */ }; diff --git a/src/emu/sound/5220intf.c b/src/emu/sound/5220intf.c index fd66066ccc5..f6695a48ea0 100644 --- a/src/emu/sound/5220intf.c +++ b/src/emu/sound/5220intf.c @@ -41,7 +41,7 @@ static void tms5220_update(void *param, stream_sample_t **inputs, stream_sample_ ***********************************************************************************************/ -static void *tms5220_start(int sndindex, int clock, const void *config) +static void *tms5220_start(const char *tag, int sndindex, int clock, const void *config) { static const struct TMS5220interface dummy = { 0 }; struct tms5220_info *info; @@ -74,9 +74,9 @@ static void *tms5220_start(int sndindex, int clock, const void *config) #if (HAS_TMC0285 || HAS_TMS5200) -static void *tms5200_start(int sndindex, int clock, const void *config) +static void *tms5200_start(const char *tag, int sndindex, int clock, const void *config) { - struct tms5220_info *info = tms5220_start(sndindex, clock, config); + struct tms5220_info *info = tms5220_start(tag, sndindex, clock, config); tms5220_set_variant(info->chip, variant_tmc0285); return info; } diff --git a/src/emu/sound/aica.c b/src/emu/sound/aica.c index ebdf29c752c..ec60ea744a5 100644 --- a/src/emu/sound/aica.c +++ b/src/emu/sound/aica.c @@ -513,7 +513,7 @@ static void AICA_StopSlot(struct _SLOT *slot,int keyoff) #define log_base_2(n) (log((float) n)/log((float) 2)) -static void AICA_Init(struct _AICA *AICA, const struct AICAinterface *intf, int sndindex) +static void AICA_Init(const char *tag, struct _AICA *AICA, const struct AICAinterface *intf, int sndindex) { int i; @@ -534,11 +534,11 @@ static void AICA_Init(struct _AICA *AICA, const struct AICAinterface *intf, int AICA->Master=0; } - if (intf->region) + AICA->AICARAM = memory_region(Machine, RGNCLASS_SOUND, tag); + if (AICA->AICARAM) { - AICA->AICARAM = memory_region(Machine, intf->region); AICA->AICARAM += intf->roffset; - AICA->AICARAM_LENGTH = memory_region_length(Machine, intf->region); + AICA->AICARAM_LENGTH = memory_region_length(Machine, RGNCLASS_SOUND, tag); AICA->RAM_MASK = AICA->AICARAM_LENGTH-1; AICA->RAM_MASK16 = AICA->RAM_MASK & 0x7ffffe; AICA->DSP.AICARAM = (UINT16 *)AICA->AICARAM; @@ -1272,7 +1272,7 @@ static void AICA_Update(void *param, stream_sample_t **inputs, stream_sample_t * AICA_DoMasterSamples(AICA, samples); } -static void *aica_start(int sndindex, int clock, const void *config) +static void *aica_start(const char *tag, int sndindex, int clock, const void *config) { const struct AICAinterface *intf; @@ -1284,7 +1284,7 @@ static void *aica_start(int sndindex, int clock, const void *config) intf = config; // init the emulation - AICA_Init(AICA, intf, sndindex); + AICA_Init(tag, AICA, intf, sndindex); // set up the IRQ callbacks { diff --git a/src/emu/sound/aica.h b/src/emu/sound/aica.h index 38541c632c3..752b83b8a59 100644 --- a/src/emu/sound/aica.h +++ b/src/emu/sound/aica.h @@ -10,7 +10,6 @@ struct AICAinterface { - int region; /* region of 2M/8M RAM */ int roffset; /* offset in the region */ void (*irq_callback)(running_machine *machine, int state); /* irq callback */ }; diff --git a/src/emu/sound/astrocde.c b/src/emu/sound/astrocde.c index b55d2023996..32ef3013481 100644 --- a/src/emu/sound/astrocde.c +++ b/src/emu/sound/astrocde.c @@ -256,7 +256,7 @@ static void astrocade_state_save_register(struct astrocade_info *chip, int sndin * *************************************/ -static void *astrocade_start(int sndindex, int clock, const void *config) +static void *astrocade_start(const char *tag, int sndindex, int clock, const void *config) { struct astrocade_info *chip; int i; diff --git a/src/emu/sound/ay8910.c b/src/emu/sound/ay8910.c index 9c3409e56b3..1844f5f7558 100644 --- a/src/emu/sound/ay8910.c +++ b/src/emu/sound/ay8910.c @@ -816,7 +816,7 @@ int ay8910_read_ym(void *chip) * *************************************/ -static void *ay8910_start(int sndindex, int clock, const void *config) +static void *ay8910_start(const char *tag, int sndindex, int clock, const void *config) { static const struct AY8910interface generic_ay8910 = { @@ -828,7 +828,7 @@ static void *ay8910_start(int sndindex, int clock, const void *config) return ay8910_start_ym(SOUND_AY8910, sndindex+16, clock, intf); } -static void *ym2149_start(int sndindex, int clock, const void *config) +static void *ym2149_start(const char *tag, int sndindex, int clock, const void *config) { static const struct AY8910interface generic_ay8910 = { diff --git a/src/emu/sound/beep.c b/src/emu/sound/beep.c index f0dbc427c1f..e13605a2de5 100644 --- a/src/emu/sound/beep.c +++ b/src/emu/sound/beep.c @@ -81,7 +81,7 @@ static void beep_sound_update(void *param,stream_sample_t **inputs, stream_sampl * *************************************/ -static void *beep_start(int sndindex, int clock, const void *config) +static void *beep_start(const char *tag, int sndindex, int clock, const void *config) { struct beep_sound *pBeep; diff --git a/src/emu/sound/bsmt2000.c b/src/emu/sound/bsmt2000.c index d94bac174a3..71b083e8829 100644 --- a/src/emu/sound/bsmt2000.c +++ b/src/emu/sound/bsmt2000.c @@ -82,22 +82,11 @@ struct _bsmt2000_chip /*************************************************************************** - GLOBAL VARIABLES -***************************************************************************/ - -const struct BSMT2000interface bsmt2000_interface_region_1 = { REGION_SOUND1 }; -const struct BSMT2000interface bsmt2000_interface_region_2 = { REGION_SOUND2 }; -const struct BSMT2000interface bsmt2000_interface_region_3 = { REGION_SOUND3 }; -const struct BSMT2000interface bsmt2000_interface_region_4 = { REGION_SOUND4 }; - - - -/*************************************************************************** FUNCTION PROTOTYPES ***************************************************************************/ /* core implementation */ -static void *bsmt2000_start(int sndindex, int clock, const void *config); +static void *bsmt2000_start(const char *tag, int sndindex, int clock, const void *config); static void bsmt2000_reset(void *_chip); static void bsmt2000_update(void *param, stream_sample_t **inputs, stream_sample_t **buffer, int length); @@ -118,9 +107,8 @@ static void set_regmap(bsmt2000_chip *chip, UINT8 posbase, UINT8 ratebase, UINT8 bsmt2000_start - initialization callback -------------------------------------------------*/ -static void *bsmt2000_start(int sndindex, int clock, const void *config) +static void *bsmt2000_start(const char *tag, int sndindex, int clock, const void *config) { - const struct BSMT2000interface *intf = config; bsmt2000_chip *chip; int voicenum; @@ -133,8 +121,8 @@ static void *bsmt2000_start(int sndindex, int clock, const void *config) chip->clock = clock; /* initialize the regions */ - chip->region_base = (INT8 *)memory_region(Machine, intf->region); - chip->total_banks = memory_region_length(Machine, intf->region) / 0x10000; + chip->region_base = (INT8 *)memory_region(Machine, RGNCLASS_SOUND, tag); + chip->total_banks = memory_region_length(Machine, RGNCLASS_SOUND, tag) / 0x10000; /* register chip-wide data for save states */ state_save_register_item("bsmt2000", sndindex * 16, chip->last_register); diff --git a/src/emu/sound/bsmt2000.h b/src/emu/sound/bsmt2000.h index 911848b7979..0dd2027988a 100644 --- a/src/emu/sound/bsmt2000.h +++ b/src/emu/sound/bsmt2000.h @@ -8,16 +8,6 @@ #ifndef BSMT2000_H #define BSMT2000_H -struct BSMT2000interface -{ - int region; /* memory region where the sample ROM lives */ -}; - WRITE16_HANDLER( BSMT2000_data_0_w ); -extern const struct BSMT2000interface bsmt2000_interface_region_1; -extern const struct BSMT2000interface bsmt2000_interface_region_2; -extern const struct BSMT2000interface bsmt2000_interface_region_3; -extern const struct BSMT2000interface bsmt2000_interface_region_4; - #endif diff --git a/src/emu/sound/c140.c b/src/emu/sound/c140.c index 241ae269d7f..5094229f3c2 100644 --- a/src/emu/sound/c140.c +++ b/src/emu/sound/c140.c @@ -455,7 +455,7 @@ static void update_stereo(void *param, stream_sample_t **inputs, stream_sample_t } } -static void *c140_start(int sndindex, int clock, const void *config) +static void *c140_start(const char *tag, int sndindex, int clock, const void *config) { const struct C140interface *intf = config; struct c140_info *info; @@ -469,8 +469,7 @@ static void *c140_start(int sndindex, int clock, const void *config) info->stream = stream_create(0,2,info->sample_rate,info,update_stereo); - if (intf->region) - info->pRom=memory_region(Machine, intf->region); + info->pRom=memory_region(Machine, RGNCLASS_SOUND, tag); /* make decompress pcm table */ //2000.06.26 CAB { diff --git a/src/emu/sound/c140.h b/src/emu/sound/c140.h index bcd0862874f..50784e3ce47 100644 --- a/src/emu/sound/c140.h +++ b/src/emu/sound/c140.h @@ -18,7 +18,6 @@ enum struct C140interface { int banking_type; - int region; }; #endif diff --git a/src/emu/sound/c352.c b/src/emu/sound/c352.c index ca2999f803c..654a859f371 100644 --- a/src/emu/sound/c352.c +++ b/src/emu/sound/c352.c @@ -71,7 +71,7 @@ struct c352_info sound_stream *stream; c352_ch_t c352_ch[32]; unsigned char *c352_rom_samples; - int c352_region; + UINT32 c352_rom_length; int sample_rate_base; INT16 level_table[256]; @@ -128,7 +128,7 @@ static void c352_mix_one_channel(struct c352_info *info, unsigned long ch, long noisecnt = info->c352_ch[ch].noisecnt; noisebuf = info->c352_ch[ch].noisebuf; - len = (UINT32)memory_region_length(Machine, info->c352_region); + len = info->c352_rom_length; for(i = 0 ; (i < sample_count) && (flag & C352_FLG_BUSY) ; i++) { offset += delta; @@ -544,18 +544,15 @@ static void c352_init(struct c352_info *info, int sndindex) } } -static void *c352_start(int sndindex, int clock, const void *config) +static void *c352_start(const char *tag, int sndindex, int clock, const void *config) { - const struct C352interface *intf; struct c352_info *info; info = auto_malloc(sizeof(*info)); memset(info, 0, sizeof(*info)); - intf = config; - - info->c352_rom_samples = memory_region(Machine, intf->region); - info->c352_region = intf->region; + info->c352_rom_samples = memory_region(Machine, RGNCLASS_SOUND, tag); + info->c352_rom_length = memory_region_length(Machine, RGNCLASS_SOUND, tag); info->sample_rate_base = clock / 192; diff --git a/src/emu/sound/c352.h b/src/emu/sound/c352.h index 7ab5896fdd1..e0b3af89ff6 100644 --- a/src/emu/sound/c352.h +++ b/src/emu/sound/c352.h @@ -1,11 +1,6 @@ #ifndef _C352_H_ #define _C352_H_ -struct C352interface -{ - int region; /* memory region of sample ROMs */ -}; - READ16_HANDLER( c352_0_r ); WRITE16_HANDLER( c352_0_w ); diff --git a/src/emu/sound/c6280.c b/src/emu/sound/c6280.c index a4c3197523d..17ab85eb596 100644 --- a/src/emu/sound/c6280.c +++ b/src/emu/sound/c6280.c @@ -310,7 +310,7 @@ static void c6280_update(void *param, stream_sample_t **inputs, stream_sample_t /* MAME specific code */ /*--------------------------------------------------------------------------*/ -static void *c6280_start(int sndindex, int clock, const void *config) +static void *c6280_start(const char *tag, int sndindex, int clock, const void *config) { int rate = clock/16; c6280_t *info; diff --git a/src/emu/sound/cdda.c b/src/emu/sound/cdda.c index 523d694799d..5f36d2e2555 100644 --- a/src/emu/sound/cdda.c +++ b/src/emu/sound/cdda.c @@ -43,7 +43,7 @@ static void cdda_update(void *param, stream_sample_t **inputs, stream_sample_t * cdda_start - audio start callback -------------------------------------------------*/ -static void *cdda_start(int sndindex, int clock, const void *config) +static void *cdda_start(const char *tag, int sndindex, int clock, const void *config) { const struct CDDAinterface *intf; cdda_info *info; diff --git a/src/emu/sound/cdp1869.c b/src/emu/sound/cdp1869.c index 06fd321ce9d..553bf903287 100644 --- a/src/emu/sound/cdp1869.c +++ b/src/emu/sound/cdp1869.c @@ -103,7 +103,7 @@ static void cdp1869_update(void *param, stream_sample_t **inputs, stream_sample_ * *************************************/ -static void *cdp1869_start(int sndindex, int clock, const void *config) +static void *cdp1869_start(const char *tag, int sndindex, int clock, const void *config) { struct CDP1869 *info; diff --git a/src/emu/sound/cem3394.c b/src/emu/sound/cem3394.c index 509bf6bff60..239fea63a33 100644 --- a/src/emu/sound/cem3394.c +++ b/src/emu/sound/cem3394.c @@ -315,7 +315,7 @@ static void cem3394_update(void *param, stream_sample_t **inputs, stream_sample_ } -static void *cem3394_start(int sndindex, int clock, const void *config) +static void *cem3394_start(const char *tag, int sndindex, int clock, const void *config) { const struct cem3394_interface *intf = config; sound_chip *chip; diff --git a/src/emu/sound/custom.c b/src/emu/sound/custom.c index c730c69e741..d54c42616c4 100644 --- a/src/emu/sound/custom.c +++ b/src/emu/sound/custom.c @@ -10,7 +10,7 @@ struct custom_info -static void *custom_start(int sndindex, int clock, const void *config) +static void *custom_start(const char *tag, int sndindex, int clock, const void *config) { struct custom_info *info; diff --git a/src/emu/sound/dac.c b/src/emu/sound/dac.c index d4271c2d452..cb32e02db41 100644 --- a/src/emu/sound/dac.c +++ b/src/emu/sound/dac.c @@ -99,7 +99,7 @@ static void DAC_build_voltable(struct dac_info *info) } -static void *dac_start(int sndindex, int clock, const void *config) +static void *dac_start(const char *tag, int sndindex, int clock, const void *config) { struct dac_info *info; diff --git a/src/emu/sound/discrete.c b/src/emu/sound/discrete.c index ff6fc8581da..15fbdabb737 100644 --- a/src/emu/sound/discrete.c +++ b/src/emu/sound/discrete.c @@ -288,7 +288,7 @@ node_description *discrete_find_node(void *chip, int node) * *************************************/ -static void *discrete_start(int sndindex, int clock, const void *config) +static void *discrete_start(const char *tag, int sndindex, int clock, const void *config) { discrete_sound_block *intf = (discrete_sound_block *)config; discrete_info *info; diff --git a/src/emu/sound/dmadac.c b/src/emu/sound/dmadac.c index 0ba8b937c6e..e0634bb79de 100644 --- a/src/emu/sound/dmadac.c +++ b/src/emu/sound/dmadac.c @@ -91,7 +91,7 @@ static void dmadac_update(void *param, stream_sample_t **inputs, stream_sample_t * *************************************/ -static void *dmadac_start(int sndindex, int clock, const void *config) +static void *dmadac_start(const char *tag, int sndindex, int clock, const void *config) { struct dmadac_channel_data *info; diff --git a/src/emu/sound/es5503.c b/src/emu/sound/es5503.c index 0914fe19928..ed0871a9361 100644 --- a/src/emu/sound/es5503.c +++ b/src/emu/sound/es5503.c @@ -224,7 +224,7 @@ static void es5503_pcm_update(void *param, stream_sample_t **inputs, stream_samp } -static void *es5503_start(int sndindex, int clock, const void *config) +static void *es5503_start(const char *tag, int sndindex, int clock, const void *config) { const struct ES5503interface *intf; int osc; diff --git a/src/emu/sound/es5506.c b/src/emu/sound/es5506.c index f674f532845..a3e180f703c 100644 --- a/src/emu/sound/es5506.c +++ b/src/emu/sound/es5506.c @@ -820,7 +820,7 @@ static void es5506_update(void *param, stream_sample_t **inputs, stream_sample_t ***********************************************************************************************/ -static void *es5506_start_common(sound_type sndtype, int sndindex, int clock, const void *config) +static void *es5506_start_common(sound_type sndtype, const char *tag, int sndindex, int clock, const void *config) { const struct ES5506interface *intf = config; struct ES5506Chip *chip; @@ -842,10 +842,10 @@ static void *es5506_start_common(sound_type sndtype, int sndindex, int clock, co chip->stream = stream_create(0, 2, clock / (16*32), chip, es5506_update); /* initialize the regions */ - chip->region_base[0] = intf->region0 ? (UINT16 *)memory_region(Machine, intf->region0) : NULL; - chip->region_base[1] = intf->region1 ? (UINT16 *)memory_region(Machine, intf->region1) : NULL; - chip->region_base[2] = intf->region2 ? (UINT16 *)memory_region(Machine, intf->region2) : NULL; - chip->region_base[3] = intf->region3 ? (UINT16 *)memory_region(Machine, intf->region3) : NULL; + chip->region_base[0] = intf->region0 ? (UINT16 *)memory_region(Machine, RGNCLASS_SOUND, intf->region0) : NULL; + chip->region_base[1] = intf->region1 ? (UINT16 *)memory_region(Machine, RGNCLASS_SOUND, intf->region1) : NULL; + chip->region_base[2] = intf->region2 ? (UINT16 *)memory_region(Machine, RGNCLASS_SOUND, intf->region2) : NULL; + chip->region_base[3] = intf->region3 ? (UINT16 *)memory_region(Machine, RGNCLASS_SOUND, intf->region3) : NULL; /* initialize the rest of the structure */ chip->master_clock = clock; @@ -872,9 +872,9 @@ static void *es5506_start_common(sound_type sndtype, int sndindex, int clock, co } -static void *es5506_start(int sndindex, int clock, const void *config) +static void *es5506_start(const char *tag, int sndindex, int clock, const void *config) { - return es5506_start_common(SOUND_ES5506, sndindex, clock, config); + return es5506_start_common(SOUND_ES5506, tag, sndindex, clock, config); } @@ -1499,7 +1499,7 @@ void ES5506_voice_bank_1_w(int voice, int bank) ***********************************************************************************************/ -static void *es5505_start(int sndindex, int clock, const void *config) +static void *es5505_start(const char *tag, int sndindex, int clock, const void *config) { const struct ES5505interface *intf = config; struct ES5506interface es5506intf; @@ -1511,7 +1511,7 @@ static void *es5505_start(int sndindex, int clock, const void *config) es5506intf.irq_callback = intf->irq_callback; es5506intf.read_port = intf->read_port; - return es5506_start_common(SOUND_ES5505, sndindex, clock, &es5506intf); + return es5506_start_common(SOUND_ES5505, tag, sndindex, clock, &es5506intf); } diff --git a/src/emu/sound/es5506.h b/src/emu/sound/es5506.h index ea74b6eb3d4..aee289521ab 100644 --- a/src/emu/sound/es5506.h +++ b/src/emu/sound/es5506.h @@ -10,8 +10,8 @@ struct ES5505interface { - int region0; /* memory region where the sample ROM lives */ - int region1; /* memory region where the sample ROM lives */ + const char * region0; /* memory region where the sample ROM lives */ + const char * region1; /* memory region where the sample ROM lives */ void (*irq_callback)(running_machine *machine, int state); /* irq callback */ UINT16 (*read_port)(void); /* input port read */ }; @@ -29,10 +29,10 @@ void ES5505_voice_bank_1_w(int voice, int bank); struct ES5506interface { - int region0; /* memory region where the sample ROM lives */ - int region1; /* memory region where the sample ROM lives */ - int region2; /* memory region where the sample ROM lives */ - int region3; /* memory region where the sample ROM lives */ + const char * region0; /* memory region where the sample ROM lives */ + const char * region1; /* memory region where the sample ROM lives */ + const char * region2; /* memory region where the sample ROM lives */ + const char * region3; /* memory region where the sample ROM lives */ void (*irq_callback)(running_machine *machine, int state); /* irq callback */ UINT16 (*read_port)(void); /* input port read */ }; diff --git a/src/emu/sound/es8712.c b/src/emu/sound/es8712.c index 6af3d7a7d9f..dda5ec3b79c 100644 --- a/src/emu/sound/es8712.c +++ b/src/emu/sound/es8712.c @@ -49,12 +49,6 @@ static const int index_shift[8] = { -1, -1, -1, -1, 2, 4, 6, 8 }; /* lookup table for the precomputed difference */ static int diff_lookup[49*16]; -/* useful interfaces */ -const struct ES8712interface es8712_interface_region_1 = { REGION_SOUND1 }; -const struct ES8712interface es8712_interface_region_2 = { REGION_SOUND2 }; -const struct ES8712interface es8712_interface_region_3 = { REGION_SOUND3 }; -const struct ES8712interface es8712_interface_region_4 = { REGION_SOUND4 }; - /********************************************************************************************** @@ -218,9 +212,8 @@ static void es8712_state_save_register(struct es8712 *chip, int sndindex) ***********************************************************************************************/ -static void *es8712_start(int sndindex, int clock, const void *config) +static void *es8712_start(const char *tag, int sndindex, int clock, const void *config) { - const struct ES8712interface *intf = config; struct es8712 *chip; chip = auto_malloc(sizeof(*chip)); @@ -233,7 +226,7 @@ static void *es8712_start(int sndindex, int clock, const void *config) chip->repeat = 0; chip->bank_offset = 0; - chip->region_base = memory_region(Machine, intf->region); + chip->region_base = memory_region(Machine, RGNCLASS_SOUND, tag); /* generate the name and create the stream */ chip->stream = stream_create(0, 1, clock, chip, es8712_update); diff --git a/src/emu/sound/es8712.h b/src/emu/sound/es8712.h index 6efb6cfb86c..053d7cbc81c 100644 --- a/src/emu/sound/es8712.h +++ b/src/emu/sound/es8712.h @@ -3,16 +3,6 @@ /* An interface for the ES8712 ADPCM chip */ -struct ES8712interface -{ - int region; /* Memory region where the sample ROM lives */ -}; - -extern const struct ES8712interface es8712_interface_region_1; -extern const struct ES8712interface es8712_interface_region_2; -extern const struct ES8712interface es8712_interface_region_3; -extern const struct ES8712interface es8712_interface_region_4; - void ES8712_play(int which); void ES8712_set_bank_base(int which, int base); void ES8712_set_frequency(int which, int frequency); diff --git a/src/emu/sound/flt_rc.c b/src/emu/sound/flt_rc.c index be2d988f884..3d8a28946a9 100644 --- a/src/emu/sound/flt_rc.c +++ b/src/emu/sound/flt_rc.c @@ -80,7 +80,7 @@ static void set_RC_info(struct filter_rc_info *info, int type, double R1, double } -static void *filter_rc_start(int sndindex, int clock, const void *config) +static void *filter_rc_start(const char *tag, int sndindex, int clock, const void *config) { struct filter_rc_info *info; const flt_rc_config *conf = config; diff --git a/src/emu/sound/flt_vol.c b/src/emu/sound/flt_vol.c index eeb58b6e31b..6e094777fcf 100644 --- a/src/emu/sound/flt_vol.c +++ b/src/emu/sound/flt_vol.c @@ -23,7 +23,7 @@ static void filter_volume_update(void *param, stream_sample_t **inputs, stream_s } -static void *filter_volume_start(int sndindex, int clock, const void *config) +static void *filter_volume_start(const char *tag, int sndindex, int clock, const void *config) { struct filter_volume_info *info; diff --git a/src/emu/sound/gaelco.c b/src/emu/sound/gaelco.c index c5fcc78dabf..53771446e66 100644 --- a/src/emu/sound/gaelco.c +++ b/src/emu/sound/gaelco.c @@ -243,7 +243,7 @@ WRITE16_HANDLER( gaelcosnd_w ) CG-1V/GAE1 Init ============================================================================*/ -static void *gaelcosnd_start(sound_type sndtype, int sndindex, int clock, const void *config) +static void *gaelcosnd_start(sound_type sndtype, const char *tag, int sndindex, int clock, const void *config) { int j, vol; const struct gaelcosnd_interface *intf = config; @@ -259,7 +259,9 @@ static void *gaelcosnd_start(sound_type sndtype, int sndindex, int clock, const info->banks[j] = intf->banks[j]; } info->stream = stream_create(0, 2, 8000, info, gaelco_update); - info->snd_data = (UINT8 *)memory_region(Machine, intf->region); + info->snd_data = (UINT8 *)memory_region(Machine, RGNCLASS_GFX, intf->gfxregion); + if (info->snd_data == NULL) + info->snd_data = (UINT8 *)memory_region(Machine, RGNCLASS_SOUND, tag); /* init volume table */ for (vol = 0; vol < VOLUME_LEVELS; vol++){ @@ -274,14 +276,14 @@ static void *gaelcosnd_start(sound_type sndtype, int sndindex, int clock, const return info; } -static void *gaelco_gae1_start(int sndindex, int clock, const void *config) +static void *gaelco_gae1_start(const char *tag, int sndindex, int clock, const void *config) { - return gaelcosnd_start(SOUND_GAELCO_GAE1, sndindex, clock, config); + return gaelcosnd_start(SOUND_GAELCO_GAE1, tag, sndindex, clock, config); } -static void *gaelco_cg1v_start(int sndindex, int clock, const void *config) +static void *gaelco_cg1v_start(const char *tag, int sndindex, int clock, const void *config) { - return gaelcosnd_start(SOUND_GAELCO_CG1V, sndindex, clock, config); + return gaelcosnd_start(SOUND_GAELCO_CG1V, tag, sndindex, clock, config); } diff --git a/src/emu/sound/gaelco.h b/src/emu/sound/gaelco.h index 40e962ea643..944e4a82dee 100644 --- a/src/emu/sound/gaelco.h +++ b/src/emu/sound/gaelco.h @@ -3,7 +3,7 @@ struct gaelcosnd_interface { - int region; /* memory region */ + const char *gfxregion; /* shared gfx region name */ int banks[4]; /* start of each ROM bank */ }; diff --git a/src/emu/sound/hc55516.c b/src/emu/sound/hc55516.c index 6b2b82d8b5a..fa75aafa902 100644 --- a/src/emu/sound/hc55516.c +++ b/src/emu/sound/hc55516.c @@ -89,19 +89,19 @@ static void *start_common(int sndindex, int clock, const void *config, } -static void *hc55516_start(int sndindex, int clock, const void *config) +static void *hc55516_start(const char *tag, int sndindex, int clock, const void *config) { return start_common(sndindex, clock, config, 0x07, TRUE); } -static void *mc3417_start(int sndindex, int clock, const void *config) +static void *mc3417_start(const char *tag, int sndindex, int clock, const void *config) { return start_common(sndindex, clock, config, 0x07, FALSE); } -static void *mc3418_start(int sndindex, int clock, const void *config) +static void *mc3418_start(const char *tag, int sndindex, int clock, const void *config) { return start_common(sndindex, clock, config, 0x0f, FALSE); } diff --git a/src/emu/sound/ics2115.c b/src/emu/sound/ics2115.c index 892b6850823..6cd51cdf96c 100644 --- a/src/emu/sound/ics2115.c +++ b/src/emu/sound/ics2115.c @@ -448,7 +448,7 @@ static UINT16 ics2115_reg_r(struct ics2115 *chip, UINT8 reg) } -static void *ics2115_start(int sndindex, int clock, const void *config) +static void *ics2115_start(const char *tag, int sndindex, int clock, const void *config) { struct ics2115 *chip; int i; @@ -458,7 +458,7 @@ static void *ics2115_start(int sndindex, int clock, const void *config) chip->intf = config; chip->index = sndindex; - chip->rom = memory_region(Machine, chip->intf->region); + chip->rom = memory_region(Machine, RGNCLASS_SOUND, tag); chip->timer[0].timer = timer_alloc(timer_cb_0, chip); chip->timer[1].timer = timer_alloc(timer_cb_1, chip); chip->ulaw = auto_malloc(256*sizeof(INT16)); diff --git a/src/emu/sound/ics2115.h b/src/emu/sound/ics2115.h index 9471a80c2b4..130ee0b7d78 100644 --- a/src/emu/sound/ics2115.h +++ b/src/emu/sound/ics2115.h @@ -2,7 +2,6 @@ #define __ICS2115_H__ struct ics2115_interface { - int region; void (*irq_cb)(running_machine *, int); }; diff --git a/src/emu/sound/iremga20.c b/src/emu/sound/iremga20.c index 53bc9734b39..aa7c3750c94 100644 --- a/src/emu/sound/iremga20.c +++ b/src/emu/sound/iremga20.c @@ -49,7 +49,6 @@ struct IremGA20_channel_def struct IremGA20_chip_def { - const struct IremGA20_interface *intf; UINT8 *rom; INT32 rom_size; sound_stream * stream; @@ -227,7 +226,7 @@ static void iremga20_reset( void *_chip ) } -static void *iremga20_start(int sndindex, int clock, const void *config) +static void *iremga20_start(const char *tag, int sndindex, int clock, const void *config) { struct IremGA20_chip_def *chip; int i; @@ -236,9 +235,8 @@ static void *iremga20_start(int sndindex, int clock, const void *config) memset(chip, 0, sizeof(*chip)); /* Initialize our chip structure */ - chip->intf = config; - chip->rom = memory_region(Machine, chip->intf->region); - chip->rom_size = memory_region_length(Machine, chip->intf->region); + chip->rom = memory_region(Machine, RGNCLASS_SOUND, tag); + chip->rom_size = memory_region_length(Machine, RGNCLASS_SOUND, tag); iremga20_reset(chip); diff --git a/src/emu/sound/iremga20.h b/src/emu/sound/iremga20.h index 015c7b86704..aa187b88521 100644 --- a/src/emu/sound/iremga20.h +++ b/src/emu/sound/iremga20.h @@ -6,10 +6,6 @@ #ifndef __IREMGA20_H__ #define __IREMGA20_H__ -struct IremGA20_interface { - int region; /* memory region of sample ROM(s) */ -}; - WRITE16_HANDLER( IremGA20_w ); READ16_HANDLER( IremGA20_r ); diff --git a/src/emu/sound/k005289.c b/src/emu/sound/k005289.c index c2e612febd2..88d036c705a 100644 --- a/src/emu/sound/k005289.c +++ b/src/emu/sound/k005289.c @@ -151,10 +151,9 @@ static void K005289_update(void *param, stream_sample_t **inputs, stream_sample_ *buffer++ = info->mixer_lookup[*mix++]; } -static void *k005289_start(int sndindex, int clock, const void *config) +static void *k005289_start(const char *tag, int sndindex, int clock, const void *config) { k005289_sound_channel *voice; - const struct k005289_interface *intf = config; struct k005289_info *info; info = auto_malloc(sizeof(*info)); @@ -173,7 +172,7 @@ static void *k005289_start(int sndindex, int clock, const void *config) if (make_mixer_table(info, 2)) return NULL; - info->sound_prom = memory_region(Machine, intf->region); + info->sound_prom = memory_region(Machine, RGNCLASS_SOUND, tag); /* reset all the voices */ voice[0].frequency = 0; diff --git a/src/emu/sound/k005289.h b/src/emu/sound/k005289.h index 71563b4e463..d0e2b00c249 100644 --- a/src/emu/sound/k005289.h +++ b/src/emu/sound/k005289.h @@ -1,11 +1,6 @@ #ifndef k005289_h #define k005289_h -struct k005289_interface -{ - int region; /* memory region */ -}; - WRITE8_HANDLER( k005289_control_A_w ); WRITE8_HANDLER( k005289_control_B_w ); WRITE8_HANDLER( k005289_pitch_A_w ); diff --git a/src/emu/sound/k007232.c b/src/emu/sound/k007232.c index b654f658cf2..af0cef57c60 100644 --- a/src/emu/sound/k007232.c +++ b/src/emu/sound/k007232.c @@ -294,43 +294,44 @@ static void KDAC_A_update(void *param, stream_sample_t **inputs, stream_sample_t /************************************************/ /* Konami PCM start */ /************************************************/ -static void *k007232_start(int sndindex, int clock, const void *config) +static void *k007232_start(const char *tag, int sndindex, int clock, const void *config) { - int i; - struct kdacApcm *info; + static const struct K007232_interface defintrf = { 0 }; + int i; + struct kdacApcm *info; - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); + info = auto_malloc(sizeof(*info)); + memset(info, 0, sizeof(*info)); - info->intf = config; + info->intf = (config != NULL) ? config : &defintrf; - /* Set up the chips */ + /* Set up the chips */ - info->pcmbuf[0] = (unsigned char *)memory_region(Machine, info->intf->bank); - info->pcmbuf[1] = (unsigned char *)memory_region(Machine, info->intf->bank); - info->pcmlimit = (unsigned int)memory_region_length(Machine, info->intf->bank); + info->pcmbuf[0] = (unsigned char *)memory_region(Machine, RGNCLASS_SOUND, tag); + info->pcmbuf[1] = (unsigned char *)memory_region(Machine, RGNCLASS_SOUND, tag); + info->pcmlimit = (unsigned int)memory_region_length(Machine, RGNCLASS_SOUND, tag); info->clock = clock; - for( i = 0; i < KDAC_A_PCM_MAX; i++ ) + for( i = 0; i < KDAC_A_PCM_MAX; i++ ) { - info->start[i] = 0; - info->step[i] = 0; - info->play[i] = 0; - info->bank[i] = 0; + info->start[i] = 0; + info->step[i] = 0; + info->play[i] = 0; + info->bank[i] = 0; } - info->vol[0][0] = 255; /* channel A output to output A */ - info->vol[0][1] = 0; - info->vol[1][0] = 0; - info->vol[1][1] = 255; /* channel B output to output B */ + info->vol[0][0] = 255; /* channel A output to output A */ + info->vol[0][1] = 0; + info->vol[1][0] = 0; + info->vol[1][1] = 255; /* channel B output to output B */ - for( i = 0; i < 0x10; i++ ) info->wreg[i] = 0; + for( i = 0; i < 0x10; i++ ) info->wreg[i] = 0; - info->stream = stream_create(0,2,clock/128,info,KDAC_A_update); + info->stream = stream_create(0,2,clock/128,info,KDAC_A_update); - KDAC_A_make_fncode(info); + KDAC_A_make_fncode(info); - return info; + return info; } /************************************************/ diff --git a/src/emu/sound/k007232.h b/src/emu/sound/k007232.h index f1736e96a9c..4d3201568e3 100644 --- a/src/emu/sound/k007232.h +++ b/src/emu/sound/k007232.h @@ -6,7 +6,6 @@ struct K007232_interface { - int bank; /* memory regions */ void (*portwritehandler)(int); }; diff --git a/src/emu/sound/k051649.c b/src/emu/sound/k051649.c index c3aa5d34519..032173a0655 100644 --- a/src/emu/sound/k051649.c +++ b/src/emu/sound/k051649.c @@ -127,7 +127,7 @@ static void K051649_update(void *param, stream_sample_t **inputs, stream_sample_ *buffer++ = info->mixer_lookup[*mix++]; } -static void *k051649_start(int sndindex, int clock, const void *config) +static void *k051649_start(const char *tag, int sndindex, int clock, const void *config) { struct k051649_info *info; diff --git a/src/emu/sound/k053260.c b/src/emu/sound/k053260.c index 795e05e419e..d9a30d9b3bb 100644 --- a/src/emu/sound/k053260.c +++ b/src/emu/sound/k053260.c @@ -194,8 +194,9 @@ static void K053260_update( void * param, stream_sample_t **inputs, stream_sampl } } -static void *k053260_start(int sndindex, int clock, const void *config) +static void *k053260_start(const char *tag, int sndindex, int clock, const void *config) { + static const struct K053260_interface defintrf = { 0 }; struct K053260_chip_def *ic; int rate = clock / 32; int i; @@ -204,11 +205,11 @@ static void *k053260_start(int sndindex, int clock, const void *config) memset(ic, 0, sizeof(*ic)); /* Initialize our chip structure */ - ic->intf = config; + ic->intf = (config != NULL) ? config : &defintrf; ic->mode = 0; - ic->rom = memory_region(Machine, ic->intf->region); - ic->rom_size = memory_region_length(Machine, ic->intf->region) - 1; + ic->rom = memory_region(Machine, RGNCLASS_SOUND, (ic->intf->rgnoverride != NULL) ? ic->intf->rgnoverride : tag); + ic->rom_size = memory_region_length(Machine, RGNCLASS_SOUND, (ic->intf->rgnoverride != NULL) ? ic->intf->rgnoverride : tag) - 1; K053260_reset( ic ); diff --git a/src/emu/sound/k053260.h b/src/emu/sound/k053260.h index 69be6b2a16d..0708e0fd3ed 100644 --- a/src/emu/sound/k053260.h +++ b/src/emu/sound/k053260.h @@ -7,7 +7,7 @@ #define __K053260_H__ struct K053260_interface { - int region; /* memory region of sample ROM(s) */ + const char *rgnoverride; timer_fired_func irq; /* called on SH1 complete cycle ( clock / 32 ) */ }; diff --git a/src/emu/sound/k054539.c b/src/emu/sound/k054539.c index e0b98c9995b..00affbfa808 100644 --- a/src/emu/sound/k054539.c +++ b/src/emu/sound/k054539.c @@ -433,7 +433,7 @@ static TIMER_CALLBACK( K054539_irq ) info->intf->irq(machine); } -static void K054539_init_chip(struct k054539_info *info, int clock, int sndindex) +static void K054539_init_chip(const char *tag, struct k054539_info *info, int clock, int sndindex) { int i; @@ -447,8 +447,8 @@ static void K054539_init_chip(struct k054539_info *info, int clock, int sndindex info->cur_ptr = 0; memset(info->ram, 0, 0x4000*2+clock/50*2); - info->rom = memory_region(Machine, info->intf->region); - info->rom_size = memory_region_length(Machine, info->intf->region); + info->rom = memory_region(Machine, RGNCLASS_SOUND, (info->intf->rgnoverride != NULL) ? info->intf->rgnoverride : tag); + info->rom_size = memory_region_length(Machine, RGNCLASS_SOUND, (info->intf->rgnoverride != NULL) ? info->intf->rgnoverride : tag); info->rom_mask = 0xffffffffU; for(i=0; i<32; i++) if((1U<<i) >= info->rom_size) { @@ -625,8 +625,9 @@ static UINT8 K054539_r(int chip, offs_t offset) return info->regs[offset]; } -static void *k054539_start(int sndindex, int clock, const void *config) +static void *k054539_start(const char *tag, int sndindex, int clock, const void *config) { + static const struct K054539interface defintrf = { 0 }; int i; struct k054539_info *info; @@ -637,7 +638,7 @@ static void *k054539_start(int sndindex, int clock, const void *config) info->K054539_gain[i] = 1.0; info->K054539_flags = K054539_RESET_FLAGS; - info->intf = config; + info->intf = (config != NULL) ? config : &defintrf; /* I've tried various equations on volume control but none worked consistently. @@ -661,7 +662,7 @@ static void *k054539_start(int sndindex, int clock, const void *config) for(i=0; i<0xf; i++) info->pantab[i] = sqrt(i) / sqrt(0xe); - K054539_init_chip(info, clock, sndindex); + K054539_init_chip(tag, info, clock, sndindex); state_save_register_postload(Machine, reset_zones, info); return info; diff --git a/src/emu/sound/k054539.h b/src/emu/sound/k054539.h index d54ee6add03..3f28c74f721 100644 --- a/src/emu/sound/k054539.h +++ b/src/emu/sound/k054539.h @@ -7,7 +7,7 @@ #define __K054539_H__ struct K054539interface { - int region; /* memory regions of sample ROM(s) */ + const char *rgnoverride; void (*apan)(double, double); /* Callback for analog output mixing levels (0..1 for each channel) */ void (*irq)(running_machine *); }; diff --git a/src/emu/sound/msm5205.c b/src/emu/sound/msm5205.c index 760649d1cd5..c0f8780a7d2 100644 --- a/src/emu/sound/msm5205.c +++ b/src/emu/sound/msm5205.c @@ -165,7 +165,7 @@ static void msm5205_reset(void *chip) * Start emulation of an MSM5205-compatible chip */ -static void *msm5205_start(int sndindex, int clock, const void *config) +static void *msm5205_start(const char *tag, int sndindex, int clock, const void *config) { struct MSM5205Voice *voice; diff --git a/src/emu/sound/msm5232.c b/src/emu/sound/msm5232.c index 6a1509f6e4f..5caed32a080 100644 --- a/src/emu/sound/msm5232.c +++ b/src/emu/sound/msm5232.c @@ -774,7 +774,7 @@ static void MSM5232_update_one(void *param, stream_sample_t **inputs, stream_sam /* MAME Interface */ -static void *msm5232_start(int sndindex, int clock, const void *config) +static void *msm5232_start(const char *tag, int sndindex, int clock, const void *config) { const struct MSM5232interface *intf = config; int rate = clock/CLOCK_RATE_DIVIDER; diff --git a/src/emu/sound/multipcm.c b/src/emu/sound/multipcm.c index 378a49330fa..f62f07e37e9 100644 --- a/src/emu/sound/multipcm.c +++ b/src/emu/sound/multipcm.c @@ -487,16 +487,15 @@ unsigned char MultiPCM_reg_r(int chip, int offset) return 0; } -static void *multipcm_start(int sndindex, int clock, const void *config) +static void *multipcm_start(const char *tag, int sndindex, int clock, const void *config) { struct _MultiPCM *ptChip; int i; - const struct MultiPCM_interface *intf = config; char mname[20]; ptChip=(struct _MultiPCM *)auto_malloc(sizeof(struct _MultiPCM)); - ptChip->ROM=(INT8 *)memory_region(Machine, intf->region); + ptChip->ROM=(INT8 *)memory_region(Machine, RGNCLASS_SOUND, tag); ptChip->Rate=(float) clock / MULTIPCM_CLOCKDIV; ptChip->stream = stream_create(0, 2, ptChip->Rate, ptChip, MultiPCM_update); diff --git a/src/emu/sound/multipcm.h b/src/emu/sound/multipcm.h index 6431406686e..92456f7eb2b 100644 --- a/src/emu/sound/multipcm.h +++ b/src/emu/sound/multipcm.h @@ -1,12 +1,6 @@ #ifndef __MultiPCM_H__ #define __MultiPCM_H__ -struct MultiPCM_interface -{ - int region; -}; - - WRITE8_HANDLER( MultiPCM_reg_0_w ); READ8_HANDLER( MultiPCM_reg_0_r); WRITE8_HANDLER( MultiPCM_reg_1_w ); diff --git a/src/emu/sound/n63701x.c b/src/emu/sound/n63701x.c index 17c1a242934..277d0666882 100644 --- a/src/emu/sound/n63701x.c +++ b/src/emu/sound/n63701x.c @@ -33,7 +33,6 @@ struct namco_63701x { voice voices[2]; sound_stream * stream; /* channel assigned by the mixer */ - const struct namco_63701x_interface *intf; /* pointer to our config data */ UINT8 *rom; /* pointer to sample ROM */ }; @@ -101,15 +100,14 @@ static void namco_63701x_update(void *param, stream_sample_t **inputs, stream_sa } -static void *namco_63701x_start(int sndindex, int clock, const void *config) +static void *namco_63701x_start(const char *tag, int sndindex, int clock, const void *config) { struct namco_63701x *chip; chip = auto_malloc(sizeof(*chip)); memset(chip, 0, sizeof(*chip)); - chip->intf = config; - chip->rom = memory_region(Machine, chip->intf->region); + chip->rom = memory_region(Machine, RGNCLASS_SOUND, tag); chip->stream = stream_create(0, 2, clock/1000, chip, namco_63701x_update); diff --git a/src/emu/sound/n63701x.h b/src/emu/sound/n63701x.h index 9fe1a9e8c65..b3b48e562c1 100644 --- a/src/emu/sound/n63701x.h +++ b/src/emu/sound/n63701x.h @@ -1,11 +1,6 @@ #ifndef namco_63701x_h #define namco_63701x_h -struct namco_63701x_interface -{ - int region; /* memory region; region MUST be 0x80000 bytes long */ -}; - void namco_63701x_write(int offset,int data); #endif diff --git a/src/emu/sound/namco.c b/src/emu/sound/namco.c index f9e75b11364..fcafb49a091 100644 --- a/src/emu/sound/namco.c +++ b/src/emu/sound/namco.c @@ -106,15 +106,19 @@ static void update_namco_waveform(struct namco_sound *chip, int offset, UINT8 da /* build the decoded waveform table */ -static int build_decoded_waveform(struct namco_sound *chip, int region) +static int build_decoded_waveform(struct namco_sound *chip, const char *region) { + UINT8 *rgnbase = memory_region(Machine, RGNCLASS_SOUND, region); INT16 *p; int size; int offset; int v; + if (rgnbase != NULL) + namco_wavedata = rgnbase; + /* 20pacgal has waves in RAM but old sound system */ - if (region == -1 && chip->num_voices != 3) + if (namco_wavedata == NULL && chip->num_voices != 3) { chip->wave_size = 1; size = 32 * 16; /* 32 samples, 16 waveforms */ @@ -133,9 +137,6 @@ static int build_decoded_waveform(struct namco_sound *chip, int region) p += size; } - if (region != -1) - namco_wavedata = memory_region(Machine, region); - /* We need waveform data. It fails if region is not specified. */ if (namco_wavedata) { @@ -354,7 +355,7 @@ static void namco_update_stereo(void *param, stream_sample_t **inputs, stream_sa } -static void *namco_start(int sndindex, int clock, const void *config) +static void *namco_start(const char *tag, int sndindex, int clock, const void *config) { sound_channel *voice; const struct namco_interface *intf = config; @@ -382,7 +383,7 @@ static void *namco_start(int sndindex, int clock, const void *config) logerror("Namco: freq fractional bits = %d: internal freq = %d, output freq = %d\n", chip->f_fracbits, chip->namco_clock, chip->sample_rate); /* build the waveform table */ - if (build_decoded_waveform(chip, intf->region)) + if (build_decoded_waveform(chip, tag)) return NULL; /* get stream channels */ diff --git a/src/emu/sound/namco.h b/src/emu/sound/namco.h index 057eb536906..8d235f3ebf4 100644 --- a/src/emu/sound/namco.h +++ b/src/emu/sound/namco.h @@ -4,7 +4,6 @@ struct namco_interface { int voices; /* number of voices */ - int region; /* memory region; -1 to use RAM (pointed to by namco_wavedata) */ int stereo; /* set to 1 to indicate stereo (e.g., System 1) */ }; diff --git a/src/emu/sound/namco52.c b/src/emu/sound/namco52.c index edb33b40049..6212bc441b4 100644 --- a/src/emu/sound/namco52.c +++ b/src/emu/sound/namco52.c @@ -130,7 +130,7 @@ static void namco_52xx_reset(void *_chip) filter2_reset(&chip->n52_lp_filter); } -static void *namco_52xx_start(int sndindex, int clock, const void *config) +static void *namco_52xx_start(const char *tag, int sndindex, int clock, const void *config) { struct namco_52xx *chip; int rate = clock/32; @@ -139,8 +139,8 @@ static void *namco_52xx_start(int sndindex, int clock, const void *config) memset(chip, 0, sizeof(*chip)); chip->intf = config; - chip->rom = memory_region(Machine, chip->intf->region); - chip->rom_len = memory_region_length(Machine, chip->intf->region); + chip->rom = memory_region(Machine, RGNCLASS_SOUND, tag); + chip->rom_len = memory_region_length(Machine, RGNCLASS_SOUND, tag); if (chip->intf->play_rate == 0) { diff --git a/src/emu/sound/namco52.h b/src/emu/sound/namco52.h index 312312dedbc..4f4ee120c0a 100644 --- a/src/emu/sound/namco52.h +++ b/src/emu/sound/namco52.h @@ -17,7 +17,6 @@ struct namco_52xx_interface { - int region; /* memory region */ double play_rate; /* Playback frequency */ double hp_filt_fc; double hp_filt_q; diff --git a/src/emu/sound/namcona.c b/src/emu/sound/namcona.c index b1630fe9b76..02192df173e 100644 --- a/src/emu/sound/namcona.c +++ b/src/emu/sound/namcona.c @@ -1124,7 +1124,7 @@ UpdateSound( void *param, stream_sample_t **inputs, stream_sample_t **buffer, in RenderSamples(chip, buffer, chip->mpMixerBuffer, length ); } /* UpdateSound */ -static void *namcona_start(int sndindex, int clock, const void *config) +static void *namcona_start(const char *tag, int sndindex, int clock, const void *config) { const struct NAMCONAinterface *intf = config; struct namcona *chip; diff --git a/src/emu/sound/nes_apu.c b/src/emu/sound/nes_apu.c index d644c431c0c..26b799ce119 100644 --- a/src/emu/sound/nes_apu.c +++ b/src/emu/sound/nes_apu.c @@ -666,7 +666,7 @@ static void NESPSG_update_sound(void *param, stream_sample_t **inputs, stream_sa /* INITIALIZE APU SYSTEM */ -static void *nesapu_start(int sndindex, int clock, const void *config) +static void *nesapu_start(const char *tag, int sndindex, int clock, const void *config) { const struct NESinterface *intf = config; struct nesapu_info *info; @@ -691,7 +691,7 @@ static void *nesapu_start(int sndindex, int clock, const void *config) info->buffer_size+=info->samps_per_sync; /* Initialize individual chips */ - (info->APU.dpcm).cpu_mem=memory_region(Machine, intf->region); + (info->APU.dpcm).cpu_mem=memory_region(Machine, RGNCLASS_CPU, intf->region); info->stream = stream_create(0, 1, rate, info, NESPSG_update_sound); diff --git a/src/emu/sound/nes_apu.h b/src/emu/sound/nes_apu.h index 6f44c23cdf5..b5d8bdc4252 100644 --- a/src/emu/sound/nes_apu.h +++ b/src/emu/sound/nes_apu.h @@ -35,7 +35,7 @@ */ struct NESinterface { - int region; /* DMC regions */ + const char *region; /* DMC regions */ }; READ8_HANDLER( NESPSG_0_r ); diff --git a/src/emu/sound/nile.c b/src/emu/sound/nile.c index 6119549d272..af459cd6925 100644 --- a/src/emu/sound/nile.c +++ b/src/emu/sound/nile.c @@ -217,16 +217,14 @@ static void nile_update(void *param, stream_sample_t **inputs, stream_sample_t * } } -static void *nile_start(int sndindex, int clock, const void *config) +static void *nile_start(const char *tag, int sndindex, int clock, const void *config) { - const struct NiLe_interface *intf = config; struct nile_info *info; info = auto_malloc(sizeof(*info)); memset(info, 0, sizeof(*info)); - info->sound_ram = (UINT8 *)memory_region(Machine, intf->region); - + info->sound_ram = (UINT8 *)memory_region(Machine, RGNCLASS_SOUND, tag); info->stream = stream_create(0, 2, 44100, info, nile_update); diff --git a/src/emu/sound/nile.h b/src/emu/sound/nile.h index 5dfd118b238..333b81d121b 100644 --- a/src/emu/sound/nile.h +++ b/src/emu/sound/nile.h @@ -1,11 +1,6 @@ #ifndef _NILE_H_ #define _NILE_H_ -struct NiLe_interface -{ - int region; -}; - extern UINT16 *nile_sound_regs; WRITE16_HANDLER(nile_snd_w); diff --git a/src/emu/sound/okim6295.c b/src/emu/sound/okim6295.c index f495429e69d..b4701da9d96 100644 --- a/src/emu/sound/okim6295.c +++ b/src/emu/sound/okim6295.c @@ -68,15 +68,10 @@ static UINT32 volume_table[16]; static int tables_computed = 0; /* useful interfaces */ -const struct OKIM6295interface okim6295_interface_region_1_pin7high = { REGION_SOUND1, 1 }; -const struct OKIM6295interface okim6295_interface_region_2_pin7high = { REGION_SOUND2, 1 }; -const struct OKIM6295interface okim6295_interface_region_3_pin7high = { REGION_SOUND3, 1 }; -const struct OKIM6295interface okim6295_interface_region_4_pin7high = { REGION_SOUND4, 1 }; +const struct OKIM6295interface okim6295_interface_pin7high = { 1 }; +const struct OKIM6295interface okim6295_interface_pin7low = { 0 }; + -const struct OKIM6295interface okim6295_interface_region_1_pin7low = { REGION_SOUND1, 0 }; -const struct OKIM6295interface okim6295_interface_region_2_pin7low = { REGION_SOUND2, 0 }; -const struct OKIM6295interface okim6295_interface_region_3_pin7low = { REGION_SOUND3, 0 }; -const struct OKIM6295interface okim6295_interface_region_4_pin7low = { REGION_SOUND4, 0 }; /********************************************************************************************** @@ -321,7 +316,7 @@ static void okim6295_state_save_register(struct okim6295 *info, int sndindex) ***********************************************************************************************/ -static void *okim6295_start(int sndindex, int clock, const void *config) +static void *okim6295_start(const char *tag, int sndindex, int clock, const void *config) { const struct OKIM6295interface *intf = config; struct okim6295 *info; @@ -335,7 +330,7 @@ static void *okim6295_start(int sndindex, int clock, const void *config) info->command = -1; info->bank_offset = 0; - info->region_base = memory_region(Machine, intf->region); + info->region_base = memory_region(Machine, RGNCLASS_SOUND, (intf->rgnoverride != NULL) ? intf->rgnoverride : tag); info->master_clock = clock; diff --git a/src/emu/sound/okim6295.h b/src/emu/sound/okim6295.h index b11a171e44b..f6585a762f5 100644 --- a/src/emu/sound/okim6295.h +++ b/src/emu/sound/okim6295.h @@ -9,21 +9,12 @@ */ struct OKIM6295interface { - int region; /* memory region where the sample ROM lives */ int pin7; + const char *rgnoverride; }; -extern const struct OKIM6295interface okim6295_interface_region_1_pin7high; -extern const struct OKIM6295interface okim6295_interface_region_2_pin7high; -extern const struct OKIM6295interface okim6295_interface_region_3_pin7high; -extern const struct OKIM6295interface okim6295_interface_region_4_pin7high; - -extern const struct OKIM6295interface okim6295_interface_region_1_pin7low; -extern const struct OKIM6295interface okim6295_interface_region_2_pin7low; -extern const struct OKIM6295interface okim6295_interface_region_3_pin7low; -extern const struct OKIM6295interface okim6295_interface_region_4_pin7low; - - +extern const struct OKIM6295interface okim6295_interface_pin7high; +extern const struct OKIM6295interface okim6295_interface_pin7low; diff --git a/src/emu/sound/pokey.c b/src/emu/sound/pokey.c index 7dab22dd3e3..b90c7982d02 100644 --- a/src/emu/sound/pokey.c +++ b/src/emu/sound/pokey.c @@ -606,7 +606,7 @@ static void register_for_save(struct POKEYregisters *chip, int index) } -static void *pokey_start(int sndindex, int clock, const void *config) +static void *pokey_start(const char *tag, int sndindex, int clock, const void *config) { struct POKEYregisters *chip; int sample_rate = clock; diff --git a/src/emu/sound/psx.c b/src/emu/sound/psx.c index a740b85b080..ebd5a806f3c 100644 --- a/src/emu/sound/psx.c +++ b/src/emu/sound/psx.c @@ -249,7 +249,7 @@ static void spu_write( UINT32 n_address, INT32 n_size ) } } -static void *psxspu_start(int sndindex, int clock, const void *config) +static void *psxspu_start(const char *tag, int sndindex, int clock, const void *config) { struct psxinfo *chip; int n_effect; diff --git a/src/emu/sound/qsound.c b/src/emu/sound/qsound.c index bbbc05afb84..c76a283fccc 100644 --- a/src/emu/sound/qsound.c +++ b/src/emu/sound/qsound.c @@ -76,7 +76,6 @@ struct QSOUND_CHANNEL struct qsound_info { /* Private variables */ - const struct QSound_interface *intf; /* Interface */ sound_stream * stream; /* Audio stream */ struct QSOUND_CHANNEL channel[QSOUND_CHANNELS]; int data; /* register latch data */ @@ -94,7 +93,7 @@ struct qsound_info static void qsound_update( void *param, stream_sample_t **inputs, stream_sample_t **outputs, int length ); static void qsound_set_command(struct qsound_info *chip, int data, int value); -static void *qsound_start(int sndindex, int clock, const void *config) +static void *qsound_start(const char *tag, int sndindex, int clock, const void *config) { struct qsound_info *chip; int i; @@ -102,10 +101,8 @@ static void *qsound_start(int sndindex, int clock, const void *config) chip = auto_malloc(sizeof(*chip)); memset(chip, 0, sizeof(chip)); - chip->intf = config; - - chip->sample_rom = (QSOUND_SRC_SAMPLE *)memory_region(Machine, chip->intf->region); - chip->sample_rom_length = memory_region_length(Machine, chip->intf->region); + chip->sample_rom = (QSOUND_SRC_SAMPLE *)memory_region(Machine, RGNCLASS_SOUND, tag); + chip->sample_rom_length = memory_region_length(Machine, RGNCLASS_SOUND, tag); memset(chip->channel, 0, sizeof(chip->channel)); diff --git a/src/emu/sound/qsound.h b/src/emu/sound/qsound.h index 00191c5a189..b66f0744bd3 100644 --- a/src/emu/sound/qsound.h +++ b/src/emu/sound/qsound.h @@ -9,10 +9,6 @@ #define QSOUND_CLOCK 4000000 /* default 4MHz clock */ -struct QSound_interface { - int region; /* memory region of sample ROM(s) */ -}; - WRITE8_HANDLER( qsound_data_h_w ); WRITE8_HANDLER( qsound_data_l_w ); WRITE8_HANDLER( qsound_cmd_w ); diff --git a/src/emu/sound/rf5c400.c b/src/emu/sound/rf5c400.c index c607df83d12..95dd75eb4e9 100644 --- a/src/emu/sound/rf5c400.c +++ b/src/emu/sound/rf5c400.c @@ -22,8 +22,6 @@ struct rf5c400_info { - const struct RF5C400interface *intf; - INT16 *rom; UINT32 rom_length; @@ -229,12 +227,12 @@ static void rf5c400_update(void *param, stream_sample_t **inputs, stream_sample_ } } -static void rf5c400_init_chip(struct rf5c400_info *info, int sndindex, int clock) +static void rf5c400_init_chip(const char *tag, struct rf5c400_info *info, int sndindex, int clock) { int i; - info->rom = (INT16*)memory_region(Machine, info->intf->region); - info->rom_length = memory_region_length(Machine, info->intf->region) / 2; + info->rom = (INT16*)memory_region(Machine, RGNCLASS_SOUND, tag); + info->rom_length = memory_region_length(Machine, RGNCLASS_SOUND, tag) / 2; // init volume table { @@ -341,16 +339,14 @@ static void rf5c400_init_chip(struct rf5c400_info *info, int sndindex, int clock } -static void *rf5c400_start(int sndindex, int clock, const void *config) +static void *rf5c400_start(const char *tag, int sndindex, int clock, const void *config) { struct rf5c400_info *info; info = auto_malloc(sizeof(*info)); memset(info, 0, sizeof(*info)); - info->intf = config; - - rf5c400_init_chip(info, sndindex, clock); + rf5c400_init_chip(tag, info, sndindex, clock); return info; } diff --git a/src/emu/sound/rf5c400.h b/src/emu/sound/rf5c400.h index 93123dc573b..dfb5e121c45 100644 --- a/src/emu/sound/rf5c400.h +++ b/src/emu/sound/rf5c400.h @@ -3,10 +3,6 @@ #ifndef __RF5C400_H__ #define __RF5C400_H__ -struct RF5C400interface { - int region; /* memory regions of sample ROM(s) */ -}; - READ16_HANDLER( RF5C400_0_r ); WRITE16_HANDLER( RF5C400_0_w ); diff --git a/src/emu/sound/rf5c68.c b/src/emu/sound/rf5c68.c index 2dbff944b41..8ffe887e2c5 100644 --- a/src/emu/sound/rf5c68.c +++ b/src/emu/sound/rf5c68.c @@ -121,7 +121,7 @@ static void rf5c68_update(void *param, stream_sample_t **inputs, stream_sample_t /* RF5C68 start */ /************************************************/ -static void *rf5c68_start(int sndindex, int clock, const void *config) +static void *rf5c68_start(const char *tag, int sndindex, int clock, const void *config) { /* allocate memory for the chip */ struct rf5c68pcm *chip = auto_malloc(sizeof(*chip)); diff --git a/src/emu/sound/s14001a.c b/src/emu/sound/s14001a.c index 8dd5033f957..035a790ab26 100644 --- a/src/emu/sound/s14001a.c +++ b/src/emu/sound/s14001a.c @@ -461,9 +461,8 @@ static void s14001a_pcm_update(void *param, stream_sample_t **inputs, stream_sam } } -static void *s14001a_start(int sndindex, int clock, const void *config) +static void *s14001a_start(const char *tag, int sndindex, int clock, const void *config) { - const struct S14001A_interface *intf; S14001AChip *chip; int i; @@ -480,9 +479,7 @@ static void *s14001a_start(int sndindex, int clock, const void *config) chip->filtervals[i] = SILENCE; } - intf = config; - - chip->SpeechRom = memory_region(Machine, intf->region); + chip->SpeechRom = memory_region(Machine, RGNCLASS_SOUND, tag); chip->stream = stream_create(0, 1, clock ? clock : Machine->sample_rate, chip, s14001a_pcm_update); diff --git a/src/emu/sound/s14001a.h b/src/emu/sound/s14001a.h index 0e4aa7a879b..4a474354e21 100644 --- a/src/emu/sound/s14001a.h +++ b/src/emu/sound/s14001a.h @@ -1,11 +1,6 @@ #ifndef _S14001A_H_ #define _S14001A_H_ -struct S14001A_interface -{ - int region; /* memory region where the sample ROM lives */ -}; - int S14001A_bsy_0_r(void); /* read BUSY pin */ void S14001A_reg_0_w(int data); /* write to input latch */ void S14001A_rst_0_w(int data); /* write to RESET pin */ diff --git a/src/emu/sound/saa1099.c b/src/emu/sound/saa1099.c index 50f24871ea9..a8e4273d204 100644 --- a/src/emu/sound/saa1099.c +++ b/src/emu/sound/saa1099.c @@ -310,7 +310,7 @@ static void saa1099_update(void *param, stream_sample_t **inputs, stream_sample_ -static void *saa1099_start(int sndindex, int clock, const void *config) +static void *saa1099_start(const char *tag, int sndindex, int clock, const void *config) { struct SAA1099 *saa; diff --git a/src/emu/sound/samples.c b/src/emu/sound/samples.c index df67c6df0f4..731ff0baa94 100644 --- a/src/emu/sound/samples.c +++ b/src/emu/sound/samples.c @@ -529,7 +529,7 @@ static STATE_POSTLOAD( samples_postload ) } -static void *samples_start(int sndindex, int clock, const void *config) +static void *samples_start(const char *tag, int sndindex, int clock, const void *config) { int i; const struct Samplesinterface *intf = config; diff --git a/src/emu/sound/scsp.c b/src/emu/sound/scsp.c index daf95d12488..2c0431894ce 100644 --- a/src/emu/sound/scsp.c +++ b/src/emu/sound/scsp.c @@ -507,7 +507,7 @@ static void SCSP_StopSlot(struct _SLOT *slot,int keyoff) #define log_base_2(n) (log((double)(n))/log(2.0)) -static void SCSP_Init(struct _SCSP *SCSP, const struct SCSPinterface *intf, int sndindex) +static void SCSP_Init(const char *tag, struct _SCSP *SCSP, const struct SCSPinterface *intf, int sndindex) { int i; @@ -528,10 +528,10 @@ static void SCSP_Init(struct _SCSP *SCSP, const struct SCSPinterface *intf, int SCSP->Master=0; } - if (intf->region) + SCSP->SCSPRAM = memory_region(Machine, RGNCLASS_SOUND, tag); + if (SCSP->SCSPRAM) { - SCSP->SCSPRAM = memory_region(Machine, intf->region); - SCSP->SCSPRAM_LENGTH = memory_region_length(Machine, intf->region); + SCSP->SCSPRAM_LENGTH = memory_region_length(Machine, RGNCLASS_SOUND, tag); SCSP->DSP.SCSPRAM = (UINT16 *)SCSP->SCSPRAM; SCSP->DSP.SCSPRAM_LENGTH = SCSP->SCSPRAM_LENGTH/2; SCSP->SCSPRAM += intf->roffset; @@ -1218,7 +1218,7 @@ static void SCSP_Update(void *param, stream_sample_t **inputs, stream_sample_t * SCSP_DoMasterSamples(SCSP, samples); } -static void *scsp_start(int sndindex, int clock, const void *config) +static void *scsp_start(const char *tag, int sndindex, int clock, const void *config) { const struct SCSPinterface *intf; @@ -1230,7 +1230,7 @@ static void *scsp_start(int sndindex, int clock, const void *config) intf = config; // init the emulation - SCSP_Init(SCSP, intf, sndindex); + SCSP_Init(tag, SCSP, intf, sndindex); // set up the IRQ callbacks { diff --git a/src/emu/sound/scsp.h b/src/emu/sound/scsp.h index 66d990e73ba..831b82f1507 100644 --- a/src/emu/sound/scsp.h +++ b/src/emu/sound/scsp.h @@ -8,7 +8,6 @@ struct SCSPinterface { - int region; /* region of 512k RAM */ int roffset; /* offset in the region */ void (*irq_callback)(running_machine *machine, int state); /* irq callback */ }; diff --git a/src/emu/sound/segapcm.c b/src/emu/sound/segapcm.c index 0026de4fe77..43f0a7f345b 100644 --- a/src/emu/sound/segapcm.c +++ b/src/emu/sound/segapcm.c @@ -77,7 +77,7 @@ static void SEGAPCM_update(void *param, stream_sample_t **inputs, stream_sample_ } } -static void *segapcm_start(int sndindex, int clock, const void *config) +static void *segapcm_start(const char *tag, int sndindex, int clock, const void *config) { const struct SEGAPCMinterface *intf = config; int mask, rom_mask, len; @@ -86,7 +86,7 @@ static void *segapcm_start(int sndindex, int clock, const void *config) spcm = auto_malloc(sizeof(*spcm)); memset(spcm, 0, sizeof(*spcm)); - spcm->rom = (const UINT8 *)memory_region(Machine, intf->region); + spcm->rom = (const UINT8 *)memory_region(Machine, RGNCLASS_SOUND, tag); spcm->ram = auto_malloc(0x800); memset(spcm->ram, 0xff, 0x800); @@ -96,7 +96,7 @@ static void *segapcm_start(int sndindex, int clock, const void *config) if(!mask) mask = BANK_MASK7>>16; - len = memory_region_length(Machine, intf->region); + len = memory_region_length(Machine, RGNCLASS_SOUND, tag); for(rom_mask = 1; rom_mask < len; rom_mask *= 2); rom_mask--; diff --git a/src/emu/sound/segapcm.h b/src/emu/sound/segapcm.h index c2ceac372c0..f1fcb08f513 100644 --- a/src/emu/sound/segapcm.h +++ b/src/emu/sound/segapcm.h @@ -15,7 +15,6 @@ struct SEGAPCMinterface { int bank; - int region; }; WRITE8_HANDLER( SegaPCM_w ); diff --git a/src/emu/sound/sid6581.c b/src/emu/sound/sid6581.c index d7ca6f78eb9..a32e80ed4b1 100644 --- a/src/emu/sound/sid6581.c +++ b/src/emu/sound/sid6581.c @@ -30,7 +30,7 @@ static void sid_update(void *token,stream_sample_t **inputs, stream_sample_t **_ -static void *sid_start(int sndindex, int clock, const void *config, SIDTYPE sidtype) +static void *sid_start(const char *tag, int sndindex, int clock, const void *config, SIDTYPE sidtype) { SID6581 *sid; const SID6581_interface *iface = (const SID6581_interface*) config; @@ -59,14 +59,14 @@ static void sid_reset(void *token) -static void *sid6581_start(int sndindex, int clock, const void *config) +static void *sid6581_start(const char *tag, int sndindex, int clock, const void *config) { return sid_start(sndindex, clock, config, MOS6581); } -static void *sid8580_start(int sndindex, int clock, const void *config) +static void *sid8580_start(const char *tag, int sndindex, int clock, const void *config) { return sid_start(sndindex, clock, config, MOS8580); } diff --git a/src/emu/sound/sn76477.c b/src/emu/sound/sn76477.c index 3933c9e82fa..dd7d5755598 100644 --- a/src/emu/sound/sn76477.c +++ b/src/emu/sound/sn76477.c @@ -2387,7 +2387,7 @@ static void state_save_register(struct SN76477 *sn) * *****************************************************************************/ -static void *sn76477_start(int sndindex, int clock, const void *config) +static void *sn76477_start(const char *tag, int sndindex, int clock, const void *config) { struct SN76477 *sn; struct SN76477interface *intf; diff --git a/src/emu/sound/sn76496.c b/src/emu/sound/sn76496.c index 6e303f9686d..197f7dd151f 100644 --- a/src/emu/sound/sn76496.c +++ b/src/emu/sound/sn76496.c @@ -343,32 +343,32 @@ static void *generic_start(int sndindex, int clock, int feedbackmask, int noiset } -static void *sn76489_start(int sndindex, int clock, const void *config) +static void *sn76489_start(const char *tag, int sndindex, int clock, const void *config) { return generic_start(sndindex, clock, 0x4000, 0x03, TRUE); } -static void *sn76489a_start(int sndindex, int clock, const void *config) +static void *sn76489a_start(const char *tag, int sndindex, int clock, const void *config) { return generic_start(sndindex, clock, 0x8000, 0x06, FALSE); } -static void *sn76494_start(int sndindex, int clock, const void *config) +static void *sn76494_start(const char *tag, int sndindex, int clock, const void *config) { return generic_start(sndindex, clock, 0x8000, 0x06, FALSE); } -static void *sn76496_start(int sndindex, int clock, const void *config) +static void *sn76496_start(const char *tag, int sndindex, int clock, const void *config) { return generic_start(sndindex, clock, 0x8000, 0x06, FALSE); } -static void *gamegear_start(int sndindex, int clock, const void *config) +static void *gamegear_start(const char *tag, int sndindex, int clock, const void *config) { return generic_start(sndindex, clock, 0x8000, 0x09, FALSE); } -static void *smsiii_start(int sndindex, int clock, const void *config) +static void *smsiii_start(const char *tag, int sndindex, int clock, const void *config) { return generic_start(sndindex, clock, 0x8000, 0x09, FALSE); } diff --git a/src/emu/sound/sp0250.c b/src/emu/sound/sp0250.c index dd9549fad63..570d4104ac5 100644 --- a/src/emu/sound/sp0250.c +++ b/src/emu/sound/sp0250.c @@ -190,7 +190,7 @@ static void sp0250_update(void *param, stream_sample_t **inputs, stream_sample_t } -static void *sp0250_start(int sndindex, int clock, const void *config) +static void *sp0250_start(const char *tag, int sndindex, int clock, const void *config) { const struct sp0250_interface *intf = config; struct sp0250 *sp; diff --git a/src/emu/sound/sp0256.c b/src/emu/sound/sp0256.c index b81dfbf51d9..94041a1a671 100644 --- a/src/emu/sound/sp0256.c +++ b/src/emu/sound/sp0256.c @@ -1169,7 +1169,7 @@ static void sp0256_update(void *param, stream_sample_t **inputs, stream_sample_t } } -static void *sp0256_start(int sndindex, int clock, const void *config) +static void *sp0256_start(const char *tag, int sndindex, int clock, const void *config) { const struct sp0256_interface *intf = config; struct sp0256 *sp; @@ -1206,7 +1206,7 @@ static void *sp0256_start(int sndindex, int clock, const void *config) /* -------------------------------------------------------------------- */ /* Setup the ROM. */ /* -------------------------------------------------------------------- */ - sp->rom = memory_region(Machine, intf->memory_region); + sp->rom = memory_region(Machine, RGNCLASS_SOUND, tag); sp0256_bitrevbuff(sp->rom, 0, 0xffff); return sp; diff --git a/src/emu/sound/sp0256.h b/src/emu/sound/sp0256.h index 981cc26521e..6e5ee2bd32a 100644 --- a/src/emu/sound/sp0256.h +++ b/src/emu/sound/sp0256.h @@ -24,7 +24,6 @@ struct sp0256_interface { void (*lrq_callback)(int state); void (*sby_callback)(int state); - int memory_region; }; void sp0256_bitrevbuff(UINT8 *buffer, unsigned int start, unsigned int length); diff --git a/src/emu/sound/speaker.c b/src/emu/sound/speaker.c index 18795380841..663112b3b08 100644 --- a/src/emu/sound/speaker.c +++ b/src/emu/sound/speaker.c @@ -36,7 +36,7 @@ static void speaker_sound_update(void *param,stream_sample_t **inputs, stream_sa -static void *speaker_start(int sndindex, int clock, const void *config) +static void *speaker_start(const char *tag, int sndindex, int clock, const void *config) { struct speaker *sp = auto_malloc(sizeof(*sp)); diff --git a/src/emu/sound/st0016.c b/src/emu/sound/st0016.c index aca4573a362..41fb92bca7f 100644 --- a/src/emu/sound/st0016.c +++ b/src/emu/sound/st0016.c @@ -124,7 +124,7 @@ static void st0016_update(void *param, stream_sample_t **inputs, stream_sample_t } } -static void *st0016_start(int sndindex, int clock, const void *config) +static void *st0016_start(const char *tag, int sndindex, int clock, const void *config) { const struct ST0016interface *intf = config; struct st0016_info *info; diff --git a/src/emu/sound/tiaintf.c b/src/emu/sound/tiaintf.c index 580c26e12ea..fcf01bdedea 100644 --- a/src/emu/sound/tiaintf.c +++ b/src/emu/sound/tiaintf.c @@ -17,7 +17,7 @@ static void tia_update(void *param, stream_sample_t **inputs, stream_sample_t ** } -static void *tia_start(int sndindex, int clock, const void *config) +static void *tia_start(const char *tag, int sndindex, int clock, const void *config) { struct tia_info *info; diff --git a/src/emu/sound/tms3615.c b/src/emu/sound/tms3615.c index 39f8f499ecc..56b0ef46f3e 100644 --- a/src/emu/sound/tms3615.c +++ b/src/emu/sound/tms3615.c @@ -77,7 +77,7 @@ void tms3615_enable_w(int chip, int enable) tms->enable = enable; } -static void *tms3615_start(int sndindex, int clock, const void *config) +static void *tms3615_start(const char *tag, int sndindex, int clock, const void *config) { struct TMS3615 *tms; diff --git a/src/emu/sound/tms36xx.c b/src/emu/sound/tms36xx.c index 710e504286e..2f5b0306887 100644 --- a/src/emu/sound/tms36xx.c +++ b/src/emu/sound/tms36xx.c @@ -485,7 +485,7 @@ void tms3617_enable_w(int chip, int enable) tms3617_enable(tms, enable); } -static void *tms36xx_start(int sndindex, int clock, const void *config) +static void *tms36xx_start(const char *tag, int sndindex, int clock, const void *config) { int j; struct TMS36XX *tms; diff --git a/src/emu/sound/upd7759.c b/src/emu/sound/upd7759.c index c9e82572133..88c26eda322 100644 --- a/src/emu/sound/upd7759.c +++ b/src/emu/sound/upd7759.c @@ -620,9 +620,10 @@ static void register_for_save(struct upd7759_chip *chip, int index) } -static void *upd7759_start(int sndindex, int clock, const void *config) +static void *upd7759_start(const char *tag, int sndindex, int clock, const void *config) { - const struct upd7759_interface *intf = config; + static const struct upd7759_interface defintrf = { 0 }; + const struct upd7759_interface *intf = (config != NULL) ? config : &defintrf; struct upd7759_chip *chip; chip = auto_malloc(sizeof(*chip)); @@ -641,9 +642,8 @@ static void *upd7759_start(int sndindex, int clock, const void *config) chip->state = STATE_IDLE; /* compute the ROM base or allocate a timer */ - if (intf->region != 0) - chip->rom = chip->rombase = memory_region(Machine, intf->region); - else + chip->rom = chip->rombase = memory_region(Machine, RGNCLASS_SOUND, tag); + if (chip->rom == NULL) chip->timer = timer_alloc(upd7759_slave_update, chip); /* set the DRQ callback */ diff --git a/src/emu/sound/upd7759.h b/src/emu/sound/upd7759.h index 1471f6c2681..d86f655289a 100644 --- a/src/emu/sound/upd7759.h +++ b/src/emu/sound/upd7759.h @@ -10,7 +10,6 @@ struct upd7759_interface { - int region; /* memory region (per chip, standalone mode only) */ void (*drqcallback)(int param); /* drq callback (per chip, slave mode only) */ }; diff --git a/src/emu/sound/vlm5030.c b/src/emu/sound/vlm5030.c index 09b2247b093..831956dc3f5 100644 --- a/src/emu/sound/vlm5030.c +++ b/src/emu/sound/vlm5030.c @@ -631,7 +631,7 @@ if( chip->interp_step != 1) /* start VLM5030 with sound rom */ /* speech_rom == 0 -> use sampling data mode */ -static void *vlm5030_start(int sndindex, int clock, const void *config) +static void *vlm5030_start(const char *tag, int sndindex, int clock, const void *config) { int emulation_rate; struct vlm5030_info *chip; @@ -650,10 +650,10 @@ static void *vlm5030_start(int sndindex, int clock, const void *config) VLM5030_reset(chip); chip->phase = PH_IDLE; - chip->rom = memory_region(Machine, chip->intf->memory_region); + chip->rom = memory_region(Machine, RGNCLASS_SOUND, tag); /* memory size */ if( chip->intf->memory_size == 0) - chip->address_mask = memory_region_length(Machine, chip->intf->memory_region)-1; + chip->address_mask = memory_region_length(Machine, RGNCLASS_SOUND, tag)-1; else chip->address_mask = chip->intf->memory_size-1; diff --git a/src/emu/sound/vlm5030.h b/src/emu/sound/vlm5030.h index 24368193945..c5e3ccb6101 100644 --- a/src/emu/sound/vlm5030.h +++ b/src/emu/sound/vlm5030.h @@ -3,7 +3,6 @@ struct VLM5030interface { - int memory_region; /* memory region of speech rom */ int memory_size; /* memory size of speech rom (0=memory region length) */ }; diff --git a/src/emu/sound/votrax.c b/src/emu/sound/votrax.c index e41f2486ea6..af2689d1f27 100644 --- a/src/emu/sound/votrax.c +++ b/src/emu/sound/votrax.c @@ -101,7 +101,7 @@ static void votrax_update_sound(void *param, stream_sample_t **inputs, stream_sa } -static void *votrax_start(int sndindex, int clock, const void *config) +static void *votrax_start(const char *tag, int sndindex, int clock, const void *config) { struct votrax_info *votrax; diff --git a/src/emu/sound/vrender0.c b/src/emu/sound/vrender0.c index cf55a4b17bb..57b37589cc8 100644 --- a/src/emu/sound/vrender0.c +++ b/src/emu/sound/vrender0.c @@ -94,7 +94,7 @@ void VR0_Snd_Set_Areas(UINT32 *Texture,UINT32 *Frame) VR0->FBBase=Frame; } -static void *vrender0_start(int sndindex, int clock, const void *config) +static void *vrender0_start(const char *tag, int sndindex, int clock, const void *config) { const struct VR0Interface *intf; struct _VR0Chip *VR0; diff --git a/src/emu/sound/wave.c b/src/emu/sound/wave.c index 3172e84018f..02f10b9a879 100644 --- a/src/emu/sound/wave.c +++ b/src/emu/sound/wave.c @@ -59,7 +59,7 @@ static void wave_sound_update(void *param,stream_sample_t **inputs, stream_sampl -static void *wave_start(int sndindex, int clock, const void *config) +static void *wave_start(const char *tag, int sndindex, int clock, const void *config) { stream_create(0, 1, Machine->sample_rate, (void *) (FPTR)sndindex, wave_sound_update); return (void *) (FPTR)(sndindex | WAVE_TOKEN_MASK); diff --git a/src/emu/sound/x1_010.c b/src/emu/sound/x1_010.c index 6f7d11ca63d..f40f1975e2b 100644 --- a/src/emu/sound/x1_010.c +++ b/src/emu/sound/x1_010.c @@ -46,10 +46,6 @@ Registers: *1 : when 0 is specified, hardware interrupt is caused(allways return soon) -Hardcoded Values: - - PCM ROM region: REGION_SOUND1 - ***************************************************************************/ #include "sndintrf.h" @@ -90,6 +86,7 @@ struct x1_010_info int rate; // Output sampling rate (Hz) sound_stream * stream; // Stream handle int address; // address eor data + const char *region; // region name int sound_enable; // sound output enable/disable UINT8 reg[0x2000]; // X1-010 Register & wave form area UINT8 HI_WORD_BUF[0x2000]; // X1-010 16bit access ram check avoidance work @@ -114,7 +111,7 @@ static void seta_update( void *param, stream_sample_t **inputs, stream_sample_t register INT8 *start, *end, data; register UINT8 *env; register UINT32 smp_offs, smp_step, env_offs, env_step, delta; - UINT8 *snd1 = memory_region(Machine, REGION_SOUND1); + UINT8 *snd1 = memory_region(Machine, RGNCLASS_SOUND, info->region); // mixer buffer zero clear memset( buffer[0], 0, length*sizeof(*buffer[0]) ); @@ -195,7 +192,7 @@ static void seta_update( void *param, stream_sample_t **inputs, stream_sample_t -static void *x1_010_start(int sndindex, int clock, const void *config) +static void *x1_010_start(const char *tag, int sndindex, int clock, const void *config) { int i; const struct x1_010_interface *intf = config; @@ -204,6 +201,7 @@ static void *x1_010_start(int sndindex, int clock, const void *config) info = auto_malloc(sizeof(*info)); memset(info, 0, sizeof(*info)); + info->region = tag; info->base_clock = clock; info->rate = clock / 1024; info->address = intf->adr; diff --git a/src/emu/sound/ymf271.c b/src/emu/sound/ymf271.c index a84d1893a2f..abc9a7a61b1 100644 --- a/src/emu/sound/ymf271.c +++ b/src/emu/sound/ymf271.c @@ -1742,8 +1742,9 @@ static void ymf271_init(YMF271Chip *chip, UINT8 *rom, void (*cb)(running_machine init_state(chip); } -static void *ymf271_start(int sndindex, int clock, const void *config) +static void *ymf271_start(const char *tag, int sndindex, int clock, const void *config) { + static const struct YMF271interface defintrf = { 0 }; const struct YMF271interface *intf; int i; YMF271Chip *chip; @@ -1753,9 +1754,9 @@ static void *ymf271_start(int sndindex, int clock, const void *config) chip->index = sndindex; chip->clock = clock; - intf = config; + intf = (config != NULL) ? config : &defintrf; - ymf271_init(chip, memory_region(Machine, intf->region), intf->irq_callback, intf->ext_read, intf->ext_write); + ymf271_init(chip, memory_region(Machine, RGNCLASS_SOUND, tag), intf->irq_callback, intf->ext_read, intf->ext_write); chip->stream = stream_create(0, 2, clock/384, chip, ymf271_update); for (i = 0; i < 256; i++) diff --git a/src/emu/sound/ymf271.h b/src/emu/sound/ymf271.h index b2bc7df8c7a..fc6ad5c882f 100644 --- a/src/emu/sound/ymf271.h +++ b/src/emu/sound/ymf271.h @@ -3,7 +3,6 @@ struct YMF271interface { - int region; /* memory region of sample ROMs */ read8_machine_func ext_read; /* external memory read */ write8_machine_func ext_write; /* external memory write */ void (*irq_callback)(running_machine *machine, int state); /* irq callback */ diff --git a/src/emu/sound/ymf278b.c b/src/emu/sound/ymf278b.c index 7705826559e..24ebbd754dc 100644 --- a/src/emu/sound/ymf278b.c +++ b/src/emu/sound/ymf278b.c @@ -667,8 +667,9 @@ static void ymf278b_init(YMF278BChip *chip, UINT8 *rom, void (*cb)(running_machi mix = auto_malloc(44100*2*sizeof(*mix)); } -static void *ymf278b_start(int sndindex, int clock, const void *config) +static void *ymf278b_start(const char *tag, int sndindex, int clock, const void *config) { + static const struct YMF278B_interface defintrf = { 0 }; const struct YMF278B_interface *intf; int i; YMF278BChip *chip; @@ -677,9 +678,9 @@ static void *ymf278b_start(int sndindex, int clock, const void *config) memset(chip, 0, sizeof(*chip)); chip->index = sndindex; - intf = config; + intf = (config != NULL) ? config : &defintrf; - ymf278b_init(chip, memory_region(Machine, intf->region), intf->irq_callback, clock); + ymf278b_init(chip, memory_region(Machine, RGNCLASS_SOUND, tag), intf->irq_callback, clock); chip->stream = stream_create(0, 2, clock/768, chip, ymf278b_pcm_update); // Volume table, 1 = -0.375dB, 8 = -3dB, 256 = -96dB diff --git a/src/emu/sound/ymf278b.h b/src/emu/sound/ymf278b.h index 739d1333a62..a7a1d6269e5 100644 --- a/src/emu/sound/ymf278b.h +++ b/src/emu/sound/ymf278b.h @@ -4,7 +4,6 @@ #define YMF278B_STD_CLOCK (33868800) /* standard clock for OPL4 */ struct YMF278B_interface { - int region; /* memory region of sample ROMs */ void (*irq_callback)(running_machine *machine, int state); /* irq callback */ }; diff --git a/src/emu/sound/ymz280b.c b/src/emu/sound/ymz280b.c index 4ded68e5731..e9872be6c17 100644 --- a/src/emu/sound/ymz280b.c +++ b/src/emu/sound/ymz280b.c @@ -627,9 +627,10 @@ static void ymz280b_update(void *param, stream_sample_t **inputs, stream_sample_ ***********************************************************************************************/ -static void *ymz280b_start(int sndindex, int clock, const void *config) +static void *ymz280b_start(const char *tag, int sndindex, int clock, const void *config) { - const struct YMZ280Binterface *intf = config; + static const struct YMZ280Binterface defintrf = { 0 }; + const struct YMZ280Binterface *intf = (config != NULL) ? config : &defintrf; struct YMZ280BChip *chip; chip = auto_malloc(sizeof(*chip)); @@ -643,7 +644,7 @@ static void *ymz280b_start(int sndindex, int clock, const void *config) /* initialize the rest of the structure */ chip->master_clock = (double)clock / 384.0; - chip->region_base = memory_region(Machine, intf->region); + chip->region_base = memory_region(Machine, RGNCLASS_SOUND, tag); chip->irq_callback = intf->irq_callback; /* create the stream */ diff --git a/src/emu/sound/ymz280b.h b/src/emu/sound/ymz280b.h index c1e644d5cf4..4355fab2d55 100644 --- a/src/emu/sound/ymz280b.h +++ b/src/emu/sound/ymz280b.h @@ -10,7 +10,6 @@ struct YMZ280Binterface { - int region; /* memory region where the sample ROM lives */ void (*irq_callback)(running_machine *machine, int state); /* irq callback */ read8_machine_func ext_read; /* external RAM read */ write8_machine_func ext_write; /* external RAM write */ diff --git a/src/emu/validity.c b/src/emu/validity.c index 7dc757df7c1..4793b337a7a 100644 --- a/src/emu/validity.c +++ b/src/emu/validity.c @@ -52,6 +52,21 @@ UINT8 your_ptr64_flag_is_wrong[(int)(5 - sizeof(void *))]; TYPE DEFINITIONS ***************************************************************************/ +typedef struct _region_entry region_entry; +struct _region_entry +{ + const char *tag; + UINT32 length; +}; + + +typedef struct _region_info region_info; +struct _region_info +{ + region_entry entries[RGNCLASS_COUNT][32]; +}; + + typedef struct _quark_entry quark_entry; struct _quark_entry { @@ -488,18 +503,18 @@ static int validate_driver(int drivnum, const machine_config *config) validate_roms - validate ROM definitions -------------------------------------------------*/ -static int validate_roms(int drivnum, const machine_config *config, UINT32 *region_length) +static int validate_roms(int drivnum, const machine_config *config, region_info *rgninfo) { const game_driver *driver = drivers[drivnum]; const rom_entry *romp; const char *last_name = "???"; - int cur_region = -1; int error = FALSE; int items_since_region = 1; int bios_flags = 0, last_bios = 0; + region_entry *currgn = NULL; /* reset region info */ - memset(region_length, 0, REGION_MAX * sizeof(*region_length)); + memset(rgninfo, 0, sizeof(*rgninfo)); /* scan the ROM entries */ for (romp = driver->rom; romp && !ROMENTRY_ISEND(romp); romp++) @@ -507,34 +522,54 @@ static int validate_roms(int drivnum, const machine_config *config, UINT32 *regi /* if this is a region, make sure it's valid, and record the length */ if (ROMENTRY_ISREGION(romp)) { - int type = ROMREGION_GETTYPE(romp); + const char *rgntag = ROMREGION_GETTAG(romp); + int rgnclass = ROMREGION_GETCLASS(romp); /* if we haven't seen any items since the last region, print a warning */ if (items_since_region == 0) mame_printf_warning("%s: %s has empty ROM region (warning)\n", driver->source_file, driver->name); items_since_region = (ROMREGION_ISERASE(romp) || ROMREGION_ISDISPOSE(romp)) ? 1 : 0; + currgn = NULL; /* check for an invalid region */ - if (type >= REGION_MAX || type <= REGION_INVALID) + if (rgnclass >= RGNCLASS_COUNT || rgnclass <= RGNCLASS_INVALID) { - mame_printf_error("%s: %s has invalid ROM_REGION type %x\n", driver->source_file, driver->name, type); + mame_printf_error("%s: %s has invalid ROM_REGION class %d\n", driver->source_file, driver->name, rgnclass); error = TRUE; - cur_region = -1; } - /* check for a duplicate */ - else if (region_length[type] != 0) + /* check for an invalid tag */ + else if (rgntag == NULL || rgntag[0] == 0) { - mame_printf_error("%s: %s has duplicate ROM_REGION type %x\n", driver->source_file, driver->name, type); + mame_printf_error("%s: %s has duplicate ROM_REGION tag \"%s\"\n", driver->source_file, driver->name, rgntag); error = TRUE; - cur_region = -1; } - /* if all looks good, remember the length and note the region */ + /* find any empty entry, checking for duplicates */ else { - cur_region = type; - region_length[type] = ROMREGION_GETLENGTH(romp); + int rgnnum; + + /* iterate over all regions found so far */ + for (rgnnum = 0; rgnnum < ARRAY_LENGTH(rgninfo->entries[rgnclass]); rgnnum++) + { + /* stop when we hit an empty */ + if (rgninfo->entries[rgnclass][rgnnum].tag == NULL) + { + currgn = &rgninfo->entries[rgnclass][rgnnum]; + currgn->tag = rgntag; + currgn->length = ROMREGION_GETLENGTH(romp); + break; + } + + /* fail if we hit a duplicate */ + if (strcmp(rgninfo->entries[rgnclass][rgnnum].tag, rgntag) == 0) + { + mame_printf_error("%s: %s has duplicate ROM_REGION type %d,\"%s\"\n", driver->source_file, driver->name, rgnclass, rgntag); + error = TRUE; + break; + } + } } } @@ -544,7 +579,7 @@ static int validate_roms(int drivnum, const machine_config *config, UINT32 *regi bios_flags = ROM_GETBIOSFLAGS(romp); if (last_bios+1 != bios_flags) { - const char *name = ROM_GETHASHDATA(romp); + const char *name = ROM_GETNAME(romp); mame_printf_error("%s: %s has non-sequential bios %s\n", driver->source_file, driver->name, name); error = TRUE; } @@ -592,11 +627,11 @@ static int validate_roms(int drivnum, const machine_config *config, UINT32 *regi } /* for any non-region ending entries, make sure they don't extend past the end */ - if (!ROMENTRY_ISREGIONEND(romp) && cur_region != -1) + if (!ROMENTRY_ISREGIONEND(romp) && currgn != NULL) { items_since_region++; - if (ROM_GETOFFSET(romp) + ROM_GETLENGTH(romp) > region_length[cur_region]) + if (ROM_GETOFFSET(romp) + ROM_GETLENGTH(romp) > currgn->length) { mame_printf_error("%s: %s has ROM %s extending past the defined memory region\n", driver->source_file, driver->name, last_name); error = TRUE; @@ -616,12 +651,12 @@ static int validate_roms(int drivnum, const machine_config *config, UINT32 *regi validate_cpu - validate CPUs and memory maps -------------------------------------------------*/ -static int validate_cpu(int drivnum, const machine_config *config, const UINT32 *region_length) +static int validate_cpu(int drivnum, const machine_config *config, region_info *rgninfo) { const game_driver *driver = drivers[drivnum]; + cpu_validity_check_func cpu_validity_check; int error = FALSE; int cpunum; - cpu_validity_check_func cpu_validity_check; /* loop over all the CPUs */ for (cpunum = 0; cpunum < MAX_CPU; cpunum++) @@ -633,15 +668,24 @@ static int validate_cpu(int drivnum, const machine_config *config, const UINT32 /* skip empty entries */ if (cpu->type == CPU_DUMMY) continue; + + /* check for valid tag */ + if (cpu->tag == NULL || cpu->tag[0] == 0) + { + mame_printf_error("%s: %s has NULL or empty CPU tag\n", driver->source_file, driver->name); + error = TRUE; + } /* check for duplicate tags */ - if (cpu->tag != NULL) + else + { for (checknum = 0; checknum < cpunum; checknum++) if (config->cpu[checknum].tag != NULL && strcmp(cpu->tag, config->cpu[checknum].tag) == 0) { mame_printf_error("%s: %s has multiple CPUs tagged as '%s'\n", driver->source_file, driver->name, cpu->tag); error = TRUE; } + } /* checks to see if this driver is using a dummy CPU */ if (cputype_get_interface(cpu->type)->get_info == dummy_get_info) @@ -652,10 +696,10 @@ static int validate_cpu(int drivnum, const machine_config *config, const UINT32 } /* check the CPU for incompleteness */ - if (!cputype_get_info_fct(cpu->type, CPUINFO_PTR_GET_CONTEXT) - || !cputype_get_info_fct(cpu->type, CPUINFO_PTR_SET_CONTEXT) - || !cputype_get_info_fct(cpu->type, CPUINFO_PTR_RESET) - || !cputype_get_info_fct(cpu->type, CPUINFO_PTR_EXECUTE)) + if (cputype_get_info_fct(cpu->type, CPUINFO_PTR_GET_CONTEXT) == NULL || + cputype_get_info_fct(cpu->type, CPUINFO_PTR_SET_CONTEXT) == NULL || + cputype_get_info_fct(cpu->type, CPUINFO_PTR_RESET) == NULL || + cputype_get_info_fct(cpu->type, CPUINFO_PTR_EXECUTE) == NULL) { mame_printf_error("%s: %s uses an incomplete CPU\n", driver->source_file, driver->name); error = TRUE; @@ -731,26 +775,40 @@ 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.generic == STATIC_ROM && !entry->region) + if ((FPTR)entry->read.generic == STATIC_ROM && entry->rgntag == NULL) { - entry->region = REGION_CPU1 + cpunum; - entry->region_offs = entry->addrstart; + entry->rgnclass = RGNCLASS_CPU; + entry->rgntag = config->cpu[cpunum].tag; + entry->rgnoffs = entry->addrstart; } /* if this entry references a memory region, validate it */ - if (entry->region && entry->share == 0) + if (entry->rgntag != NULL && entry->share == 0) { - offs_t length = region_length[entry->region]; - - if (length == 0) + int rgnnum; + + /* loop over entries in the class */ + for (rgnnum = 0; rgnnum < ARRAY_LENGTH(rgninfo->entries[entry->rgnclass]); rgnnum++) { - mame_printf_error("%s: %s CPU %d space %d memory map entry %X-%X references non-existant region %d\n", driver->source_file, driver->name, cpunum, spacenum, entry->addrstart, entry->addrend, entry->region); - error = TRUE; - } - else if (entry->region_offs + (byteend - bytestart + 1) > length) - { - mame_printf_error("%s: %s CPU %d space %d memory map entry %X-%X extends beyond region %d size (%X)\n", driver->source_file, driver->name, cpunum, spacenum, entry->addrstart, entry->addrend, entry->region, length); - error = TRUE; + /* stop if we hit an empty */ + if (rgninfo->entries[entry->rgnclass][rgnnum].tag == NULL) + { + mame_printf_error("%s: %s CPU %d space %d memory map entry %X-%X references non-existant region %d,\"%s\"\n", driver->source_file, driver->name, cpunum, spacenum, entry->addrstart, entry->addrend, entry->rgnclass, entry->rgntag); + error = TRUE; + break; + } + + /* if we hit a match, check against the length */ + if (strcmp(rgninfo->entries[entry->rgnclass][rgnnum].tag, entry->rgntag) == 0) + { + offs_t length = rgninfo->entries[entry->rgnclass][rgnnum].length; + if (entry->rgnoffs + (byteend - bytestart + 1) > length) + { + mame_printf_error("%s: %s CPU %d space %d memory map entry %X-%X extends beyond region %d,\"%s\" size (%X)\n", driver->source_file, driver->name, cpunum, spacenum, entry->addrstart, entry->addrend, entry->rgnclass, entry->rgntag, length); + error = TRUE; + } + break; + } } } @@ -892,7 +950,7 @@ static int validate_display(int drivnum, const machine_config *config) configuration -------------------------------------------------*/ -static int validate_gfx(int drivnum, const machine_config *config, const UINT32 *region_length) +static int validate_gfx(int drivnum, const machine_config *config, region_info *rgninfo) { const game_driver *driver = drivers[drivnum]; int error = FALSE; @@ -903,10 +961,10 @@ static int validate_gfx(int drivnum, const machine_config *config, const UINT32 return FALSE; /* iterate over graphics decoding entries */ - for (gfxnum = 0; gfxnum < MAX_GFX_ELEMENTS && config->gfxdecodeinfo[gfxnum].memory_region != -1; gfxnum++) + for (gfxnum = 0; gfxnum < MAX_GFX_ELEMENTS && config->gfxdecodeinfo[gfxnum].gfxlayout != NULL; gfxnum++) { const gfx_decode_entry *gfx = &config->gfxdecodeinfo[gfxnum]; - int region = gfx->memory_region; + const char *region = gfx->memory_region; int xscale = (config->gfxdecodeinfo[gfxnum].xscale == 0) ? 1 : config->gfxdecodeinfo[gfxnum].xscale; int yscale = (config->gfxdecodeinfo[gfxnum].yscale == 0) ? 1 : config->gfxdecodeinfo[gfxnum].yscale; const gfx_layout *gl = gfx->gfxlayout; @@ -916,33 +974,57 @@ static int validate_gfx(int drivnum, const machine_config *config, const UINT32 UINT16 height = gl->height; UINT32 total = gl->total; - /* if we have a valid region, and we're not using auto-sizing, check the decode against the region length */ - if (region && !IS_FRAC(total)) + /* make sure the region exists */ + if (region != NULL) { - int len, avail, plane, start; - UINT32 charincrement = gl->charincrement; - const UINT32 *poffset = gl->planeoffset; - - /* determine which plane is the largest */ - start = 0; - for (plane = 0; plane < planes; plane++) - if (poffset[plane] > start) - start = poffset[plane]; - start &= ~(charincrement - 1); - - /* determine the total length based on this info */ - len = total * charincrement; - - /* do we have enough space in the region to cover the whole decode? */ - avail = region_length[region] - (gfx->start & ~(charincrement/8-1)); + int rgnnum; - /* if not, this is an error */ - if ((start + len) / 8 > avail) + /* loop over gfx regions */ + for (rgnnum = 0; rgnnum < ARRAY_LENGTH(rgninfo->entries[RGNCLASS_GFX]); rgnnum++) { - mame_printf_error("%s: %s has gfx[%d] extending past allocated memory\n", driver->source_file, driver->name, gfxnum); - error = TRUE; + /* stop if we hit an empty */ + if (rgninfo->entries[RGNCLASS_GFX][rgnnum].tag == NULL) + { + mame_printf_error("%s: %s has gfx[%d] referencing non-existent region \"%s\"\n", driver->source_file, driver->name, gfxnum, region); + error = TRUE; + break; + } + + /* if we hit a match, check against the length */ + if (strcmp(rgninfo->entries[RGNCLASS_GFX][rgnnum].tag, region) == 0) + { + /* if we have a valid region, and we're not using auto-sizing, check the decode against the region length */ + if (!IS_FRAC(total)) + { + int len, avail, plane, start; + UINT32 charincrement = gl->charincrement; + const UINT32 *poffset = gl->planeoffset; + + /* determine which plane is the largest */ + start = 0; + for (plane = 0; plane < planes; plane++) + if (poffset[plane] > start) + start = poffset[plane]; + start &= ~(charincrement - 1); + + /* determine the total length based on this info */ + len = total * charincrement; + + /* do we have enough space in the region to cover the whole decode? */ + avail = rgninfo->entries[RGNCLASS_GFX][rgnnum].length - (gfx->start & ~(charincrement/8-1)); + + /* if not, this is an error */ + if ((start + len) / 8 > avail) + { + mame_printf_error("%s: %s has gfx[%d] extending past allocated memory of region \"%s\"\n", driver->source_file, driver->name, gfxnum, region); + error = TRUE; + } + } + break; + } } } + if (israw) { if (total != RGN_FRAC(1,1)) @@ -1502,8 +1584,8 @@ int mame_validitychecks(const game_driver *curdriver) for (drivnum = 0; drivers[drivnum]; drivnum++) { const game_driver *driver = drivers[drivnum]; - UINT32 region_length[REGION_MAX]; machine_config *config; + region_info rgninfo; /* ASG -- trying this for a while to see if submission failures increase */ #if 1 @@ -1524,12 +1606,12 @@ int mame_validitychecks(const game_driver *curdriver) /* validate the ROM information */ rom_checks -= osd_profiling_ticks(); - error = validate_roms(drivnum, config, region_length) || error; + error = validate_roms(drivnum, config, &rgninfo) || error; rom_checks += osd_profiling_ticks(); /* validate the CPU information */ cpu_checks -= osd_profiling_ticks(); - error = validate_cpu(drivnum, config, region_length) || error; + error = validate_cpu(drivnum, config, &rgninfo) || error; cpu_checks += osd_profiling_ticks(); /* validate the display */ @@ -1539,7 +1621,7 @@ int mame_validitychecks(const game_driver *curdriver) /* validate the graphics decoding */ gfx_checks -= osd_profiling_ticks(); - error = validate_gfx(drivnum, config, region_length) || error; + error = validate_gfx(drivnum, config, &rgninfo) || error; gfx_checks += osd_profiling_ticks(); /* validate input ports */ diff --git a/src/emu/video.c b/src/emu/video.c index 95d0bdca23f..d3dbd670bb6 100644 --- a/src/emu/video.c +++ b/src/emu/video.c @@ -339,7 +339,7 @@ void video_init(running_machine *machine) /* call the PALETTE_INIT function */ if (machine->config->init_palette != NULL) - (*machine->config->init_palette)(machine, memory_region(machine, REGION_PROMS)); + (*machine->config->init_palette)(machine, memory_region(machine, RGNCLASS_PROMS, "proms")); /* actually decode the graphics */ if (machine->config->gfxdecodeinfo != NULL) @@ -476,9 +476,9 @@ static void allocate_graphics(running_machine *machine, const gfx_decode_entry * int i; /* loop over all elements */ - for (i = 0; i < MAX_GFX_ELEMENTS && gfxdecodeinfo[i].memory_region != -1; i++) + for (i = 0; i < MAX_GFX_ELEMENTS && gfxdecodeinfo[i].gfxlayout != NULL; i++) { - int region_length = 8 * memory_region_length(machine, gfxdecodeinfo[i].memory_region); + int region_length = 8 * memory_region_length(machine, RGNCLASS_GFX, gfxdecodeinfo[i].memory_region); int xscale = (gfxdecodeinfo[i].xscale == 0) ? 1 : gfxdecodeinfo[i].xscale; int yscale = (gfxdecodeinfo[i].yscale == 0) ? 1 : gfxdecodeinfo[i].yscale; UINT32 *extpoffs, extxoffs[MAX_ABS_GFX_SIZE], extyoffs[MAX_ABS_GFX_SIZE]; @@ -610,9 +610,9 @@ static void decode_graphics(running_machine *machine, const gfx_decode_entry *gf if (machine->gfx[i] != NULL) { /* if we have a valid region, decode it now */ - if (gfxdecodeinfo[i].memory_region > REGION_INVALID) + if (gfxdecodeinfo[i].memory_region != NULL) { - UINT8 *region_base = memory_region(machine, gfxdecodeinfo[i].memory_region); + UINT8 *region_base = memory_region(machine, RGNCLASS_GFX, gfxdecodeinfo[i].memory_region); gfx_element *gfx = machine->gfx[i]; int j; |