Fixed memory freeing so that is it released in the opposite order

it was originally allocated.

Changed machine->region() to return a pointer to the now-public
region_info class.

Added new member function space() to the device_config, along with
shorter constants to be used (AS_PROGRAM, AS_DATA, AS_IO). With no 
parameters, space() returns the first address space, which is 
commonly the only space present. Updated a few devices that referenced 
the old space[] array to call the new function instead.

Added #define to emualloc to ensure delete can't be freely used.
This commit is contained in:
Aaron Giles 2010-01-11 18:02:38 +00:00
parent 2441940e7a
commit a9c5a5a27e
15 changed files with 229 additions and 161 deletions

View File

@ -342,10 +342,7 @@ INLINE cpu_debug_data *cpu_get_debug_data(const device_config *device)
INLINE const address_space *cpu_get_address_space(const device_config *device, int spacenum)
{
/* it is faster to pull this from the pre-fetched data, but only after we've started */
if (device->token != NULL)
return device->space[spacenum];
return memory_find_address_space(device, spacenum);
return device->space(spacenum);
}
#endif /* __CPUEXEC_H__ */

View File

@ -204,12 +204,12 @@ void debug_cpu_init(running_machine *machine)
/* add a global symbol for the current instruction pointer */
symtable_add_register(info->symtable, "cycles", NULL, get_cycles, NULL);
if (cpu->space[ADDRESS_SPACE_PROGRAM] != NULL)
symtable_add_register(info->symtable, "logunmap", (void *)cpu->space[ADDRESS_SPACE_PROGRAM], get_logunmap, set_logunmap);
if (cpu->space[ADDRESS_SPACE_DATA] != NULL)
symtable_add_register(info->symtable, "logunmapd", (void *)cpu->space[ADDRESS_SPACE_DATA], get_logunmap, set_logunmap);
if (cpu->space[ADDRESS_SPACE_IO] != NULL)
symtable_add_register(info->symtable, "logunmapi", (void *)cpu->space[ADDRESS_SPACE_IO], get_logunmap, set_logunmap);
if (cpu->space(AS_PROGRAM) != NULL)
symtable_add_register(info->symtable, "logunmap", (void *)cpu->space(AS_PROGRAM), get_logunmap, set_logunmap);
if (cpu->space(AS_DATA) != NULL)
symtable_add_register(info->symtable, "logunmapd", (void *)cpu->space(AS_DATA), get_logunmap, set_logunmap);
if (cpu->space(AS_IO) != NULL)
symtable_add_register(info->symtable, "logunmapi", (void *)cpu->space(AS_IO), get_logunmap, set_logunmap);
/* add all registers into it */
for (regnum = 0; regnum < MAX_REGS; regnum++)

View File

@ -174,7 +174,7 @@ device_config *device_list_add(device_list *devlist, const device_config *owner,
device->tokenbytes = 0;
device->region = NULL;
device->regionbytes = 0;
memset((void *)device->space, 0, sizeof(device->space));
memset((void *)device->addrspace, 0, sizeof(device->addrspace));
device->execute = NULL;
/* append the tag */
@ -636,7 +636,7 @@ void device_list_start(running_machine *machine)
device->region = memory_region(machine, device->tag);
device->regionbytes = memory_region_length(machine, device->tag);
for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++)
device->space[spacenum] = memory_find_address_space(device, spacenum);
device->addrspace[spacenum] = memory_find_address_space(device, spacenum);
device->execute = (device_execute_func)device_get_info_fct(device, DEVINFO_FCT_EXECUTE);
}

View File

@ -191,7 +191,6 @@ enum
#define devtag_get_device(mach,tag) device_list_find_by_tag(&(mach)->config->devicelist, tag)
#define devtag_reset(mach,tag) device_reset(devtag_get_device(mach, tag))
#define devtag_get_address_space(mach,tag,space)
#define devtag_get_info_int(mach,tag,state) device_get_info_int(devtag_get_device(mach, tag), state)
#define devtag_get_info_ptr(mach,tag,state) device_get_info_ptr(devtag_get_device(mach, tag), state)
@ -299,9 +298,19 @@ union deviceinfo
/* the configuration for a general device */
enum device_space
{
AS_PROGRAM = 0,
AS_DATA = 1,
AS_IO = 2
};
class device_config
{
public:
inline const address_space *space(int index = 0) const;
inline const address_space *space(device_space index) const;
/* device relationships (always valid) */
device_config * next; /* next device (of any type/class) */
device_config * owner; /* device that owns us, or NULL if nobody */
@ -328,7 +337,7 @@ public:
UINT32 tokenbytes; /* size of the token data allocated */
UINT8 * region; /* pointer to region with the device's tag, or NULL */
UINT32 regionbytes; /* size of the region, in bytes */
const address_space * space[ADDRESS_SPACES]; /* auto-discovered address spaces */
const address_space * addrspace[ADDRESS_SPACES]; /* auto-discovered address spaces */
device_execute_func execute; /* quick pointer to execute callback */
};
@ -481,4 +490,21 @@ INLINE const device_config *device_list_find_by_tag(const device_list *devlist,
}
/*-------------------------------------------------
space - return an address space within a
device
-------------------------------------------------*/
inline const address_space *device_config::space(int index) const
{
return (token != NULL) ? addrspace[index] : memory_find_address_space(this, index);
}
inline const address_space *device_config::space(device_space index) const
{
return space(static_cast<int>(index));
}
#endif /* __DEVINTRF_H__ */

View File

@ -87,13 +87,13 @@
#include "mconfig.h"
#include "driver.h"
// the running machine
#include "mame.h"
// machine-wide utilities
#include "romload.h"
#include "state.h"
// the running machine
#include "mame.h"
// video-related
#include "drawgfx.h"
#include "tilemap.h"

View File

@ -53,6 +53,15 @@ const int memory_block_alloc_chunk = 256;
/***************************************************************************
MACROS
***************************************************************************/
// enable deletion
#undef delete
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
@ -190,7 +199,8 @@ void dump_unfreed_mem(void)
-------------------------------------------------*/
resource_pool::resource_pool()
: listlock(osd_lock_alloc())
: listlock(osd_lock_alloc()),
ordered_head(NULL)
{
memset(hash, 0, sizeof(hash));
}
@ -217,9 +227,18 @@ resource_pool::~resource_pool()
void resource_pool::add(resource_pool_item &item)
{
osd_lock_acquire(listlock);
// insert into hash table
int hashval = reinterpret_cast<FPTR>(item.ptr) % hash_prime;
item.next = hash[hashval];
hash[hashval] = &item;
// insert into ordered list
item.ordered_next = ordered_head;
if (ordered_head != NULL)
ordered_head->ordered_prev = &item;
ordered_head = &item;
osd_lock_release(listlock);
}
@ -244,8 +263,19 @@ void resource_pool::remove(void *ptr)
// must match the pointer
if ((*scanptr)->ptr == ptr)
{
// remove from hash table
resource_pool_item *deleteme = *scanptr;
*scanptr = deleteme->next;
// remove from ordered list
if (deleteme->ordered_prev != NULL)
deleteme->ordered_prev->ordered_next = deleteme->ordered_next;
else
ordered_head = deleteme->ordered_next;
if (deleteme->ordered_next != NULL)
deleteme->ordered_next->ordered_prev = deleteme->ordered_prev;
// delete the object and break
delete deleteme;
break;
}
@ -290,14 +320,13 @@ bool resource_pool::contains(void *_ptrstart, void *_ptrend)
osd_lock_acquire(listlock);
resource_pool_item *item = NULL;
for (int hashval = 0; hashval < hash_prime; hashval++)
for (item = hash[hashval]; item != NULL; item = item->next)
{
UINT8 *objstart = reinterpret_cast<UINT8 *>(item->ptr);
UINT8 *objend = objstart + item->size;
if (ptrstart >= objstart && ptrend <= objend)
goto found;
}
for (item = ordered_head; item != NULL; item = item->ordered_next)
{
UINT8 *objstart = reinterpret_cast<UINT8 *>(item->ptr);
UINT8 *objend = objstart + item->size;
if (ptrstart >= objstart && ptrend <= objend)
goto found;
}
found:
osd_lock_release(listlock);
@ -313,13 +342,11 @@ found:
void resource_pool::clear()
{
osd_lock_acquire(listlock);
for (int hashval = 0; hashval < hash_prime; hashval++)
while (hash[hashval] != NULL)
{
resource_pool_item *deleteme = hash[hashval];
hash[hashval] = deleteme->next;
delete deleteme;
}
// important: delete in reverse order of adding
while (ordered_head != NULL)
remove(ordered_head->ptr);
osd_lock_release(listlock);
}
@ -471,8 +498,9 @@ void memory_entry::report_unfreed()
// check for leaked memory
UINT32 total = 0;
for (int hashval = 0; hashval < hash_prime; hashval++)
for (memory_entry *entry = hash[hashval]; entry; entry = entry->next)
for (int hashnum = 0; hashnum < hash_prime; hashnum++)
for (memory_entry *entry = hash[hashnum]; entry != NULL; entry = entry->next)
if (entry->file != NULL)
{
if (total == 0)

View File

@ -64,11 +64,15 @@ private:
public:
resource_pool_item(void *_ptr, size_t _size)
: next(NULL),
ordered_next(NULL),
ordered_prev(NULL),
ptr(_ptr),
size(_size) { }
virtual ~resource_pool_item() { }
resource_pool_item * next;
resource_pool_item * ordered_next;
resource_pool_item * ordered_prev;
void * ptr;
size_t size;
};
@ -138,8 +142,9 @@ public:
private:
static const int hash_prime = 193;
resource_pool_item * hash[hash_prime];
osd_lock * listlock;
resource_pool_item * hash[hash_prime];
resource_pool_item * ordered_head;
};
@ -219,4 +224,14 @@ void operator delete(void *ptr, const char *file, int line, const zeromem_t &);
void operator delete[](void *ptr, const char *file, int line, const zeromem_t &);
/***************************************************************************
ADDITIONAL MACROS
***************************************************************************/
// disable direct deletion
#define delete __error_use_pool_free_mechanisms__
#endif /* __EMUALLOC_H__ */

View File

@ -152,9 +152,9 @@ static void eeprom_write(const device_config *device, int bit)
if (eestate->serial_buffer[i] == '1') address |= 1;
}
if (eestate->intf->data_bits == 16)
eestate->data_bits = memory_read_word(device->space[0], address * 2);
eestate->data_bits = memory_read_word(device->space(), address * 2);
else
eestate->data_bits = memory_read_byte(device->space[0], address);
eestate->data_bits = memory_read_byte(device->space(), address);
eestate->read_address = address;
eestate->clock_count = 0;
eestate->sending = 1;
@ -176,9 +176,9 @@ logerror("EEPROM erase address %02x\n",address);
if (eestate->locked == 0)
{
if (eestate->intf->data_bits == 16)
memory_write_word(device->space[0], address * 2, 0x0000);
memory_write_word(device->space(), address * 2, 0x0000);
else
memory_write_byte(device->space[0], address, 0x00);
memory_write_byte(device->space(), address, 0x00);
}
else
logerror("Error: EEPROM is locked\n");
@ -205,9 +205,9 @@ logerror("EEPROM write %04x to address %02x\n",data,address);
if (eestate->locked == 0)
{
if (eestate->intf->data_bits == 16)
memory_write_word(device->space[0], address * 2, data);
memory_write_word(device->space(), address * 2, data);
else
memory_write_byte(device->space[0], address, data);
memory_write_byte(device->space(), address, data);
}
else
logerror("Error: EEPROM is locked\n");
@ -296,9 +296,9 @@ WRITE_LINE_DEVICE_HANDLER( eeprom_set_clock_line )
{
eestate->read_address = (eestate->read_address + 1) & ((1 << eestate->intf->address_bits) - 1);
if (eestate->intf->data_bits == 16)
eestate->data_bits = memory_read_word(device->space[0], eestate->read_address * 2);
eestate->data_bits = memory_read_word(device->space(), eestate->read_address * 2);
else
eestate->data_bits = memory_read_byte(device->space[0], eestate->read_address);
eestate->data_bits = memory_read_byte(device->space(), eestate->read_address);
eestate->clock_count = 0;
logerror("EEPROM read %04x from address %02x\n",eestate->data_bits,eestate->read_address);
}
@ -325,7 +325,7 @@ static DEVICE_NVRAM( eeprom )
{
UINT8 *buffer = auto_alloc_array(device->machine, UINT8, eeprom_bytes);
for (offs = 0; offs < eeprom_bytes; offs++)
buffer[offs] = memory_read_byte(device->space[0], offs);
buffer[offs] = memory_read_byte(device->space(), offs);
mame_fwrite(file, buffer, eeprom_bytes);
auto_free(device->machine, buffer);
}
@ -334,7 +334,7 @@ static DEVICE_NVRAM( eeprom )
UINT8 *buffer = auto_alloc_array(device->machine, UINT8, eeprom_bytes);
mame_fread(file, buffer, eeprom_bytes);
for (offs = 0; offs < eeprom_bytes; offs++)
memory_write_byte(device->space[0], offs, buffer[offs]);
memory_write_byte(device->space(), offs, buffer[offs]);
auto_free(device->machine, buffer);
}
else
@ -348,14 +348,14 @@ static DEVICE_NVRAM( eeprom )
default_value = config->default_value;
for (offs = 0; offs < eeprom_length; offs++)
if (eestate->intf->data_bits == 8)
memory_write_byte(device->space[0], offs, default_value);
memory_write_byte(device->space(), offs, default_value);
else
memory_write_word(device->space[0], offs * 2, default_value);
memory_write_word(device->space(), offs * 2, default_value);
/* handle hard-coded data from the driver */
if (config->default_data != NULL)
for (offs = 0; offs < config->default_data_size; offs++)
memory_write_byte(device->space[0], offs, config->default_data[offs]);
memory_write_byte(device->space(), offs, config->default_data[offs]);
/* populate from a memory region if present */
if (device->region != NULL)
@ -371,9 +371,9 @@ static DEVICE_NVRAM( eeprom )
for (offs = 0; offs < eeprom_length; offs++)
if (eestate->intf->data_bits == 8)
memory_write_byte(device->space[0], offs, device->region[offs]);
memory_write_byte(device->space(), offs, device->region[offs]);
else
memory_write_word(device->space[0], offs * 2, ((UINT16 *)device->region)[offs]);
memory_write_word(device->space(), offs * 2, ((UINT16 *)device->region)[offs]);
}
}
}

View File

@ -97,17 +97,6 @@
TYPE DEFINITIONS
***************************************************************************/
typedef struct _region_info region_info;
struct _region_info
{
region_info * next;
astring name;
UINT32 length;
UINT32 flags;
UINT8 * base;
};
typedef struct _callback_item callback_item;
struct _callback_item
{
@ -750,6 +739,31 @@ int mame_is_paused(running_machine *machine)
MEMORY REGIONS
***************************************************************************/
/*-------------------------------------------------
region_info - constructor for a memory region
-------------------------------------------------*/
region_info::region_info(running_machine *_machine, const char *_name, UINT32 _length, UINT32 _flags)
: machine(_machine),
next(NULL),
name(_name),
length(_length),
flags(_flags),
base(auto_alloc_array(_machine, UINT8, _length))
{
}
/*-------------------------------------------------
~region_info - memory region destructor
-------------------------------------------------*/
region_info::~region_info()
{
auto_free(machine, base);
}
/*-------------------------------------------------
memory_region_alloc - allocates memory for a
region
@ -767,12 +781,7 @@ UINT8 *memory_region_alloc(running_machine *machine, const char *name, UINT32 le
fatalerror("memory_region_alloc called with duplicate region name \"%s\"\n", name);
/* allocate the region */
info = auto_alloc(machine, region_info);
info->next = NULL;
info->name.cpy(name);
info->length = length;
info->flags = flags;
info->base = auto_alloc_array(machine, UINT8, length);
info = auto_alloc(machine, region_info(machine, name, length, flags));
/* attempt to put is in the hash table */
tagerr = mame->regionmap.add_unique_hash(name, info, FALSE);
@ -784,7 +793,7 @@ UINT8 *memory_region_alloc(running_machine *machine, const char *name, UINT32 le
/* hook us into the list */
*infoptr = info;
return info->base;
return reinterpret_cast<UINT8 *>(info->base);
}
@ -809,36 +818,39 @@ void memory_region_free(running_machine *machine, const char *name)
mame->regionmap.remove(info->name);
/* free the region */
auto_free(machine, info->base);
auto_free(machine, info);
break;
}
}
/*-------------------------------------------------
memory_region_info - return a pointer to the
information struct for a given memory region
-------------------------------------------------*/
region_info *memory_region_info(running_machine *machine, const char *name)
{
mame_private *mame = machine->mame_data;
/* NULL tag always fails */
if (name == NULL)
return NULL;
/* look up the region and return the base */
return mame->regionmap.find_hash_only(name);
}
/*-------------------------------------------------
memory_region - returns pointer to a memory
region
-------------------------------------------------*/
UINT8 *memory_region(running_machine *machine, const char *name, UINT32 *length, UINT32 *flags)
UINT8 *memory_region(running_machine *machine, const char *name)
{
mame_private *mame = machine->mame_data;
region_info *info;
/* NULL tag always fails */
if (name == NULL)
return NULL;
/* look up the region and return the base */
info = mame->regionmap.find_hash_only(name);
if (info == NULL)
return NULL;
if (length != NULL)
*length = info->length;
if (flags != NULL)
*flags = info->flags;
return info->base;
const region_info *region = machine->region(name);
return (region != NULL) ? reinterpret_cast<UINT8 *>(region->base) : NULL;
}
@ -849,16 +861,8 @@ UINT8 *memory_region(running_machine *machine, const char *name, UINT32 *length,
UINT32 memory_region_length(running_machine *machine, const char *name)
{
mame_private *mame = machine->mame_data;
region_info *info;
/* NULL tag always fails */
if (name == NULL)
return 0;
/* look up the region and return the length */
info = mame->regionmap.find_hash_only(name);
return (info != NULL) ? info->length : 0;
const region_info *region = machine->region(name);
return (region != NULL) ? region->length : NULL;
}
@ -869,16 +873,8 @@ UINT32 memory_region_length(running_machine *machine, const char *name)
UINT32 memory_region_flags(running_machine *machine, const char *name)
{
mame_private *mame = machine->mame_data;
region_info *info;
/* NULL tag always fails */
if (name == NULL)
return 0;
/* look up the region and return the flags */
info = mame->regionmap.find_hash_only(name);
return (info != NULL) ? info->flags : 0;
const region_info *region = machine->region(name);
return (region != NULL) ? region->flags : NULL;
}
@ -889,20 +885,8 @@ UINT32 memory_region_flags(running_machine *machine, const char *name)
const char *memory_region_next(running_machine *machine, const char *name)
{
mame_private *mame = machine->mame_data;
region_info *info;
/* if there's nothing in this class, fail immediately */
if (mame->regionlist == NULL)
return NULL;
/* NULL means return the first */
if (name == NULL)
return mame->regionlist->name;
/* look up the region and return the next guy */
info = mame->regionmap.find_hash_only(name);
return (info != NULL && info->next != NULL) ? info->next->name.cstr() : NULL;
const region_info *region = machine->region(name);
return (region != NULL && region->next != NULL) ? region->next->name.cstr() : NULL;
}

View File

@ -155,8 +155,24 @@ typedef struct _generic_audio_private generic_audio_private;
typedef void (*output_callback_func)(void *param, const char *format, va_list argptr);
/* return a pointer to a specified memory region */
UINT8 *memory_region(running_machine *machine, const char *name, UINT32 *length = NULL, UINT32 *flags = NULL);
// memory region
class region_info
{
DISABLE_COPYING(region_info);
running_machine *machine;
public:
region_info(running_machine *machine, const char *_name, UINT32 _length, UINT32 _flags);
~region_info();
region_info * next;
astring name;
UINT32 length;
UINT32 flags;
UINT8 * base;
};
/* this structure holds generic pointers that are commonly used */
typedef struct _generic_pointers generic_pointers;
@ -189,7 +205,7 @@ public:
inline const device_config *device(const char *tag);
inline const input_port_config *port(const char *tag);
template<class T> T *region(const char *tag, UINT32 *length = NULL, UINT32 *flags = NULL);
inline const region_info *region(const char *tag);
resource_pool respool; /* pool of resources for this machine */
@ -255,8 +271,6 @@ public:
};
typedef struct _mame_system_tm mame_system_tm;
struct _mame_system_tm
{
@ -370,8 +384,11 @@ UINT8 *memory_region_alloc(running_machine *machine, const char *name, UINT32 le
/* free an allocated memory region */
void memory_region_free(running_machine *machine, const char *name);
/* return a pointer to the information struct for a given memory region */
region_info *memory_region_info(running_machine *machine, const char *name);
/* return a pointer to a specified memory region */
//UINT8 *memory_region(running_machine *machine, const char *name, UINT32 *length = NULL, UINT32 *flags = NULL);
UINT8 *memory_region(running_machine *machine, const char *name);
/* return the size (in bytes) of a specified memory region */
UINT32 memory_region_length(running_machine *machine, const char *name);
@ -453,9 +470,9 @@ inline const input_port_config *running_machine::port(const char *tag)
return input_port_by_tag(&portlist, tag);
}
template<class T> T *running_machine::region(const char *tag, UINT32 *length, UINT32 *flags)
inline const region_info *running_machine::region(const char *tag)
{
return reinterpret_cast<T *>(memory_region(this, tag, length, flags));
return memory_region_info(this, tag);
}

View File

@ -214,7 +214,7 @@ static void generate_adpcm(okim6295_state *chip, struct ADPCMVoice *voice, INT16
while (samples)
{
/* compute the new amplitude and update the current step */
int nibble = memory_raw_read_byte(chip->device->space[0], base + sample / 2) >> (((sample & 1) << 2) ^ 4);
int nibble = memory_raw_read_byte(chip->device->space(), base + sample / 2) >> (((sample & 1) << 2) ^ 4);
/* output to the buffer, scaling by the volume */
/* signal in range -2048..2047, volume in range 2..32 => signal * volume / 2 in range -32768..32767 */
@ -405,7 +405,7 @@ void okim6295_set_bank_base(const device_config *device, int base)
if (!info->bank_installed && base != 0)
{
/* override our memory map with a bank */
memory_install_read_bank(device->space[0], 0x00000, 0x3ffff, 0, 0, device->tag);
memory_install_read_bank(device->space(), 0x00000, 0x3ffff, 0, 0, device->tag);
info->bank_installed = TRUE;
}
@ -496,14 +496,14 @@ WRITE8_DEVICE_HANDLER( okim6295_w )
/* determine the start/stop positions */
base = info->command * 8;
start = memory_raw_read_byte(device->space[0], base + 0) << 16;
start |= memory_raw_read_byte(device->space[0], base + 1) << 8;
start |= memory_raw_read_byte(device->space[0], base + 2) << 0;
start = memory_raw_read_byte(device->space(), base + 0) << 16;
start |= memory_raw_read_byte(device->space(), base + 1) << 8;
start |= memory_raw_read_byte(device->space(), base + 2) << 0;
start &= 0x3ffff;
stop = memory_raw_read_byte(device->space[0], base + 3) << 16;
stop |= memory_raw_read_byte(device->space[0], base + 4) << 8;
stop |= memory_raw_read_byte(device->space[0], base + 5) << 0;
stop = memory_raw_read_byte(device->space(), base + 3) << 16;
stop |= memory_raw_read_byte(device->space(), base + 4) << 8;
stop |= memory_raw_read_byte(device->space(), base + 5) << 0;
stop &= 0x3ffff;
/* set up the voice to play this sample */

View File

@ -57,7 +57,7 @@ public:
};
class region_info
class region_array
{
public:
region_entry entries[256];
@ -402,7 +402,7 @@ static int validate_driver(int drivnum, const machine_config *config, game_drive
validate_roms - validate ROM definitions
-------------------------------------------------*/
static int validate_roms(int drivnum, const machine_config *config, region_info *rgninfo, game_driver_map &roms)
static int validate_roms(int drivnum, const machine_config *config, region_array *rgninfo, game_driver_map &roms)
{
const game_driver *driver = drivers[drivnum];
int bios_flags = 0, last_bios = 0;
@ -704,7 +704,7 @@ static int validate_display(int drivnum, const machine_config *config)
configuration
-------------------------------------------------*/
static int validate_gfx(int drivnum, const machine_config *config, region_info *rgninfo)
static int validate_gfx(int drivnum, const machine_config *config, region_array *rgninfo)
{
const game_driver *driver = drivers[drivnum];
int error = FALSE;
@ -1245,7 +1245,7 @@ static int validate_sound(int drivnum, const machine_config *config)
checks
-------------------------------------------------*/
static int validate_devices(int drivnum, const machine_config *config, const input_port_list *portlist, region_info *rgninfo)
static int validate_devices(int drivnum, const machine_config *config, const input_port_list *portlist, region_array *rgninfo)
{
int error = FALSE;
const game_driver *driver = drivers[drivnum];
@ -1500,7 +1500,7 @@ int mame_validitychecks(const game_driver *curdriver)
const game_driver *driver = drivers[drivnum];
input_port_list portlist;
machine_config *config;
region_info rgninfo;
region_array rgninfo;
/* non-debug builds only care about games in the same driver */
if (curdriver != NULL && strcmp(curdriver->source_file, driver->source_file) != 0)

View File

@ -729,22 +729,22 @@ static void mapper9_latch( const device_config *ppu, offs_t offset )
if((offset & 0x1ff0) == 0x0fd0 && MMC2_bank_latch[0] != 0xfd)
{
MMC2_bank_latch[0] = 0xfd;
pc10_set_videorom_bank(ppu->space[0]->machine, 0, 4, MMC2_bank[0], 4);
pc10_set_videorom_bank(ppu->machine, 0, 4, MMC2_bank[0], 4);
}
else if((offset & 0x1ff0) == 0x0fe0 && MMC2_bank_latch[0] != 0xfe)
{
MMC2_bank_latch[0] = 0xfe;
pc10_set_videorom_bank(ppu->space[0]->machine, 0, 4, MMC2_bank[1], 4);
pc10_set_videorom_bank(ppu->machine, 0, 4, MMC2_bank[1], 4);
}
else if((offset & 0x1ff0) == 0x1fd0 && MMC2_bank_latch[1] != 0xfd)
{
MMC2_bank_latch[1] = 0xfd;
pc10_set_videorom_bank(ppu->space[0]->machine, 4, 4, MMC2_bank[2], 4);
pc10_set_videorom_bank(ppu->machine, 4, 4, MMC2_bank[2], 4);
}
else if((offset & 0x1ff0) == 0x1fe0 && MMC2_bank_latch[1] != 0xfe)
{
MMC2_bank_latch[1] = 0xfe;
pc10_set_videorom_bank(ppu->space[0]->machine, 4, 4, MMC2_bank[3], 4);
pc10_set_videorom_bank(ppu->machine, 4, 4, MMC2_bank[3], 4);
}
}

View File

@ -557,8 +557,8 @@ VIDEO_UPDATE( atarisy1 )
static void decode_gfx(running_machine *machine, UINT16 *pflookup, UINT16 *molookup)
{
atarisy1_state *state = (atarisy1_state *)machine->driver_data;
UINT8 *prom1 = &memory_region(machine, "proms")[0x000];
UINT8 *prom2 = &memory_region(machine, "proms")[0x200];
UINT8 *prom1 = &machine->region("proms")->base[0x000];
UINT8 *prom2 = &machine->region("proms")->base[0x200];
int obj, i;
/* reset the globals */
@ -649,7 +649,8 @@ static int get_bank(running_machine *machine, UINT8 prom1, UINT8 prom2, int bpp)
return state->bank_gfx[bpp - 4][bank_index];
/* if the bank is out of range, call it 0 */
if (0x80000 * (bank_index - 1) >= memory_region_length(machine, "tiles"))
const region_info *tiles = machine->region("tiles");
if (0x80000 * (bank_index - 1) >= tiles->length)
return 0;
/* don't have one? let's make it ... first find any empty slot */
@ -659,7 +660,7 @@ static int get_bank(running_machine *machine, UINT8 prom1, UINT8 prom2, int bpp)
assert(gfx_index != MAX_GFX_ELEMENTS);
/* decode the graphics */
srcdata = &memory_region(machine, "tiles")[0x80000 * (bank_index - 1)];
srcdata = &tiles->base[0x80000 * (bank_index - 1)];
switch (bpp)
{
case 4:

View File

@ -424,14 +424,14 @@ static void draw_background( const device_config *device, UINT8 *line_priority )
pos = ((index1 & 0x380) >> 4) | ((index1 & 0x1f) >> 2);
page = (index1 & 0x0c00) >> 10;
address = 0x3c0 + pos;
color_byte = memory_read_byte(device->space[0], (((page * 0x400) + address) & 0xfff) + 0x2000);
color_byte = memory_read_byte(device->space(), (((page * 0x400) + address) & 0xfff) + 0x2000);
/* figure out which bits in the color table to use */
color_bits = ((index1 & 0x40) >> 4) + (index1 & 0x02);
// page2 is the output of the nametable read (this section is the FIRST read per tile!)
address = index1 & 0x3ff;
page2 = memory_read_byte(device->space[0], index1);
page2 = memory_read_byte(device->space(), index1);
// 27/12/2002
if (ppu_latch)
@ -449,8 +449,8 @@ static void draw_background( const device_config *device, UINT8 *line_priority )
// plus something that accounts for y
address += scroll_y_fine;
plane1 = memory_read_byte(device->space[0], (address & 0x1fff));
plane2 = memory_read_byte(device->space[0], (address + 8) & 0x1fff);
plane1 = memory_read_byte(device->space(), (address & 0x1fff));
plane2 = memory_read_byte(device->space(), (address + 8) & 0x1fff);
/* render the pixel */
for (i = 0; i < 8; i++)
@ -600,8 +600,8 @@ static void draw_sprites( const device_config *device, UINT8 *line_priority )
if (size == 8)
index1 += ((sprite_page == 0) ? 0 : 0x1000);
plane1 = memory_read_byte(device->space[0], (index1 + sprite_line) & 0x1fff);
plane2 = memory_read_byte(device->space[0], (index1 + sprite_line + 8) & 0x1fff);
plane1 = memory_read_byte(device->space(), (index1 + sprite_line) & 0x1fff);
plane2 = memory_read_byte(device->space(), (index1 + sprite_line + 8) & 0x1fff);
/* if there are more than 8 sprites on this line, set the flag */
if (spriteCount == 8)
@ -1059,14 +1059,14 @@ READ8_DEVICE_HANDLER( ppu2c0x_r )
if (this_ppu->videomem_addr >= 0x3f00)
{
this_ppu->data_latch = memory_read_byte(device->space[0], this_ppu->videomem_addr);
this_ppu->data_latch = memory_read_byte(device->space(), this_ppu->videomem_addr);
// buffer the mirrored NT data
this_ppu->buffered_data = memory_read_byte(device->space[0], this_ppu->videomem_addr & 0x2fff);
this_ppu->buffered_data = memory_read_byte(device->space(), this_ppu->videomem_addr & 0x2fff);
}
else
{
this_ppu->data_latch = this_ppu->buffered_data;
this_ppu->buffered_data = memory_read_byte(device->space[0], this_ppu->videomem_addr);
this_ppu->buffered_data = memory_read_byte(device->space(), this_ppu->videomem_addr);
}
this_ppu->videomem_addr += this_ppu->add;
@ -1213,12 +1213,12 @@ WRITE8_DEVICE_HANDLER( ppu2c0x_w )
if (tempAddr < 0x2000)
{
/* store the data */
memory_write_byte(device->space[0], tempAddr, data);
memory_write_byte(device->space(), tempAddr, data);
}
else
{
memory_write_byte(device->space[0], tempAddr, data);
memory_write_byte(device->space(), tempAddr, data);
}
/* increment the address */
this_ppu->videomem_addr += this_ppu->add;