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.
This commit is contained in:
Aaron Giles 2008-07-28 09:35:36 +00:00
parent 1b81188229
commit 27fed1ec97
1456 changed files with 43366 additions and 43966 deletions

View File

@ -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);

View File

@ -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));
}

View File

@ -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);

View File

@ -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:
case EXPSPACE_USER:
case EXPSPACE_GFX:
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_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 (name == NULL)
break;
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)
/* make sure we get a valid base before proceeding */
if (base != NULL)
{
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;
}
UINT32 length = memory_region_length(Machine, rgnclass, rgntag);
UINT32 flags = memory_region_flags(Machine, rgnclass, rgntag);
/* process if it exists */
if (rgnnum != -1)
{
UINT8 *base = memory_region(Machine, rgnnum);
/* 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;
/* call ourself recursively until we are byte-sized */
if (size > 1)
{
int halfsize = size / 2;
UINT64 r0, r1;
/* 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);
/* 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);
/* 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) >> 8)) - 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)) - 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:
case EXPSPACE_USER:
case EXPSPACE_GFX:
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_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 (name == NULL)
break;
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;
UINT8 *base = memory_region(Machine, rgnclass, rgntag);
/* convert to a region number */
switch (rgntype)
/* make sure we get a valid base before proceeding */
if (base != NULL)
{
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;
}
UINT32 length = memory_region_length(Machine, rgnclass, rgntag);
UINT32 flags = memory_region_flags(Machine, rgnclass, rgntag);
/* process if it exists */
if (rgnnum != -1)
{
UINT8 *base = memory_region(Machine, rgnnum);
/* 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;
}
else
{
r0 = (data >> (8 * halfsize)) & halfmask;
r1 = data & halfmask;
}
/* 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;
/* 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);
}
/* 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;
}
/* 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;
}
}
}

View File

@ -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();

View File

@ -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 */
@ -206,6 +215,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;
@ -1598,6 +1605,55 @@ static EXPRERR execute_tokens(parsed_expression *expr, UINT64 *result)
MISC HELPERS
***************************************************************************/
/*-------------------------------------------------
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
@ -1605,20 +1661,18 @@ static EXPRERR execute_tokens(parsed_expression *expr, UINT64 *result)
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);

View File

@ -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 */

View File

@ -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 */

View File

@ -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

View File

@ -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"

View File

@ -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;

View File

@ -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 */
};

View File

@ -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,72 +755,61 @@ 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;
mame_private *mame = machine->mame_data;
region_info *info;
assert(rgnclass < RGNCLASS_COUNT);
/* if we're already an index, stop there */
if (num < MAX_MEMORY_REGIONS)
return num;
/* 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);
/* scan for a match */
for (i = 0; i < MAX_MEMORY_REGIONS; i++)
if (mame->mem_region[i].type == num)
return i;
return -1;
/* 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
region
-------------------------------------------------*/
void free_memory_region(running_machine *machine, int num)
{
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]));
}
}
@ -879,13 +818,23 @@ void free_memory_region(running_machine *machine, int num)
region
-------------------------------------------------*/
UINT8 *memory_region(running_machine *machine, int num)
UINT8 *memory_region(running_machine *machine, int rgnclass, const char *name)
{
mame_private *mame = machine->mame_data;
region_info *info;
assert(rgnclass < RGNCLASS_COUNT);
/* NULL tag always fails */
if (name == NULL)
return NULL;
/* convert to an index and return the result */
num = memory_region_to_index(mame, num);
return (num >= 0) ? mame->mem_region[num].base : 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;
}
@ -894,28 +843,23 @@ UINT8 *memory_region(running_machine *machine, int num)
memory region
-------------------------------------------------*/
UINT32 memory_region_length(running_machine *machine, int num)
UINT32 memory_region_length(running_machine *machine, int rgnclass, const char *name)
{
mame_private *mame = machine->mame_data;
region_info *info;
assert(rgnclass < RGNCLASS_COUNT);
/* convert to an index and return the result */
num = memory_region_to_index(mame, num);
return (num >= 0) ? mame->mem_region[num].length : 0;
}
/* NULL tag always fails */
if (name == NULL)
return 0;
/*-------------------------------------------------
memory_region_type - returns the type of a
memory region
-------------------------------------------------*/
UINT32 memory_region_type(running_machine *machine, int num)
{
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;
/* 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;
}
@ -924,13 +868,76 @@ UINT32 memory_region_type(running_machine *machine, int num)
memory region
-------------------------------------------------*/
UINT32 memory_region_flags(running_machine *machine, int num)
UINT32 memory_region_flags(running_machine *machine, int rgnclass, const char *name)
{
mame_private *mame = machine->mame_data;
region_info *info;
assert(rgnclass < RGNCLASS_COUNT);
/* convert to an index and return the result */
num = memory_region_to_index(mame, num);
return (num >= 0) ? mame->mem_region[num].flags : 0;
/* 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_next - 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)
{
mame_private *mame = machine->mame_data;
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_class_name - return the name of
the given memory region class
-------------------------------------------------*/
const char *memory_region_class_name(int rgnclass, int lowercase)
{
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);

View File

@ -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);

View File

@ -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 */

View File

@ -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),

View File

@ -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;
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;
/* 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)

View File

@ -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_DISPOSE 0x00001000
#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_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_GROUPMASK 0x0000f000 /* load data in groups of this size + 1 */
#define ROM_GROUPSIZE(n) ((((n) - 1) & 15) << 12)
#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 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 ----- */

View File

@ -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);

View File

@ -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);

View File

@ -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 */

View File

@ -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;

View File

@ -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 =
{

View File

@ -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;

View File

@ -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,

View File

@ -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 */
};
/************************************************/

View File

@ -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,

View File

@ -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 */
};
/************************************************/

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;
}

View File

@ -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 */
};

View File

@ -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;
}

View File

@ -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
{

View File

@ -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 */
};

View File

@ -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;

View File

@ -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 =
{

View File

@ -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;

View File

@ -81,23 +81,12 @@ 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);

View File

@ -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

View File

@ -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
{

View File

@ -18,7 +18,6 @@ enum
struct C140interface {
int banking_type;
int region;
};
#endif

View File

@ -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;

View File

@ -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 );

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -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 */
};

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -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 */
};

View File

@ -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);
}

View File

@ -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));

View File

@ -2,7 +2,6 @@
#define __ICS2115_H__
struct ics2115_interface {
int region;
void (*irq_cb)(running_machine *, int);
};

View File

@ -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);

View File

@ -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 );

View File

@ -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;

View File

@ -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 );

View File

@ -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;
}
/************************************************/

View File

@ -6,7 +6,6 @@
struct K007232_interface
{
int bank; /* memory regions */
void (*portwritehandler)(int);
};

View File

@ -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;

View File

@ -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 );

View File

@ -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 ) */
};

View File

@ -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;

View File

@ -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 *);
};

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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 );

View File

@ -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);

View File

@ -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

View File

@ -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 */

View File

@ -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) */
};

View File

@ -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)
{

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -35,7 +35,7 @@
*/
struct NESinterface
{
int region; /* DMC regions */
const char *region; /* DMC regions */
};
READ8_HANDLER( NESPSG_0_r );

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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));

View File

@ -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 );

View File

@ -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;
}

View File

@ -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 );

Some files were not shown because too many files have changed in this diff Show More