mirror of
https://github.com/holub/mame
synced 2025-04-25 09:50:04 +03:00
(MESS) consolidation + cleanup, part2. nw.
This commit is contained in:
parent
116cfaedb3
commit
c3e67737f8
@ -759,7 +759,7 @@ WRITE8_MEMBER(nes_asn_device::write_h)
|
||||
READ8_MEMBER(nes_asn_device::read_m)
|
||||
{
|
||||
LOG_MMC(("Ai Senshi Nicol read_m, offset: %04x\n", offset));
|
||||
return m_prg[((m_latch * 0x2000) + (offset & 0x1fff)) & (m_prg.count() - 1)];
|
||||
return m_prg[((m_latch * 0x2000) + (offset & 0x1fff)) & (m_prg_size - 1)];
|
||||
}
|
||||
|
||||
|
||||
@ -923,7 +923,7 @@ WRITE8_MEMBER(nes_whirl2706_device::write_h)
|
||||
READ8_MEMBER(nes_whirl2706_device::read_m)
|
||||
{
|
||||
LOG_MMC(("whirl2706 read_m, offset: %04x\n", offset));
|
||||
return m_prg[(m_latch * 0x2000 + (offset & 0x1fff)) & (m_prg.count() - 1)];
|
||||
return m_prg[(m_latch * 0x2000 + (offset & 0x1fff)) & (m_prg_size - 1)];
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
@ -1060,7 +1060,7 @@ WRITE8_MEMBER(nes_smb2ja_device::write_h)
|
||||
READ8_MEMBER(nes_smb2ja_device::read_m)
|
||||
{
|
||||
LOG_MMC(("smb2ja read_m, offset: %04x\n", offset));
|
||||
return m_prg[(0xfe * 0x2000 + (offset & 0x1fff)) & (m_prg.count() - 1)];
|
||||
return m_prg[(0xfe * 0x2000 + (offset & 0x1fff)) & (m_prg_size - 1)];
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
@ -1118,7 +1118,7 @@ WRITE8_MEMBER(nes_smb2jb_device::write_l)
|
||||
READ8_MEMBER(nes_smb2jb_device::read_m)
|
||||
{
|
||||
LOG_MMC(("smb2jb read_m, offset: %04x\n", offset));
|
||||
return m_prg[((0x0f * 0x2000) + (offset & 0x1fff)) & (m_prg.count() - 1)];
|
||||
return m_prg[((0x0f * 0x2000) + (offset & 0x1fff)) & (m_prg_size - 1)];
|
||||
}
|
||||
|
||||
/* This goes to 0x4020-0x403f & 0x40a0-0x40bf */
|
||||
|
@ -378,7 +378,7 @@ WRITE8_MEMBER(nes_ks7032_device::ks7032_write)
|
||||
READ8_MEMBER(nes_ks7032_device::read_m)
|
||||
{
|
||||
LOG_MMC(("ks7032 read_m, offset: %04x\n", offset));
|
||||
return m_prg[((m_reg[4] * 0x2000) + (offset & 0x1fff)) & (m_prg.count() - 1)];
|
||||
return m_prg[((m_reg[4] * 0x2000) + (offset & 0x1fff)) & (m_prg_size - 1)];
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
|
@ -380,19 +380,19 @@ inline UINT8 nes_exrom_device::base_chr_r(int bank, UINT32 offset)
|
||||
break;
|
||||
}
|
||||
|
||||
return m_vrom[helper & (m_vrom.bytes() - 1)];
|
||||
return m_vrom[helper & (m_vrom_size - 1)];
|
||||
}
|
||||
|
||||
inline UINT8 nes_exrom_device::split_chr_r(UINT32 offset)
|
||||
{
|
||||
UINT32 helper = (m_split_bank * 0x1000) + (offset & 0x3f8) + (m_split_yst & 7);
|
||||
return m_vrom[helper & (m_vrom.bytes() - 1)];
|
||||
return m_vrom[helper & (m_vrom_size - 1)];
|
||||
}
|
||||
|
||||
inline UINT8 nes_exrom_device::bg_ex1_chr_r(UINT32 offset)
|
||||
{
|
||||
UINT32 helper = (m_ex1_bank * 0x1000) + (offset & 0xfff);
|
||||
return m_vrom[helper & (m_vrom.bytes() - 1)];
|
||||
return m_vrom[helper & (m_vrom_size - 1)];
|
||||
}
|
||||
|
||||
READ8_MEMBER(nes_exrom_device::chr_r)
|
||||
|
@ -718,9 +718,9 @@ void nes_cart_slot_device::call_load_ines()
|
||||
|
||||
// SETUP step 5: allocate pointers for PRG/VROM
|
||||
if (prg_size)
|
||||
m_cart->prg_alloc(prg_size);
|
||||
m_cart->prg_alloc(prg_size, tag());
|
||||
if (vrom_size)
|
||||
m_cart->vrom_alloc(vrom_size);
|
||||
m_cart->vrom_alloc(vrom_size, tag());
|
||||
|
||||
// if there is a trainer, skip it for the moment
|
||||
if (m_cart->get_trainer())
|
||||
|
@ -556,11 +556,11 @@ void nes_cart_slot_device::call_load_pcb()
|
||||
logerror("-- PRG WRAM: %d\n", prgram_size);
|
||||
|
||||
// SETUP steps 5/6: allocate pointers for PRG/VROM and load the data!
|
||||
m_cart->prg_alloc(prg_size);
|
||||
m_cart->prg_alloc(prg_size, tag());
|
||||
memcpy(m_cart->get_prg_base(), get_software_region("prg"), prg_size);
|
||||
if (vrom_size)
|
||||
{
|
||||
m_cart->vrom_alloc(vrom_size);
|
||||
m_cart->vrom_alloc(vrom_size, tag());
|
||||
memcpy(m_cart->get_vrom_base(), get_software_region("chr"), vrom_size);
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,11 @@ const device_type NES_CART_SLOT = &device_creator<nes_cart_slot_device>;
|
||||
|
||||
device_nes_cart_interface::device_nes_cart_interface(const machine_config &mconfig, device_t &device)
|
||||
: device_slot_card_interface(mconfig, device),
|
||||
m_prg(NULL),
|
||||
m_vrom(NULL),
|
||||
m_ciram(NULL),
|
||||
m_prg_size(0),
|
||||
m_vrom_size(0),
|
||||
m_mapper_sram(NULL),
|
||||
m_mapper_sram_size(0),
|
||||
m_ce_mask(0),
|
||||
@ -140,9 +144,14 @@ device_nes_cart_interface::~device_nes_cart_interface()
|
||||
// pointer allocators
|
||||
//-------------------------------------------------
|
||||
|
||||
void device_nes_cart_interface::prg_alloc(size_t size)
|
||||
void device_nes_cart_interface::prg_alloc(size_t size, const char *tag)
|
||||
{
|
||||
m_prg.resize(size);
|
||||
if (m_prg == NULL)
|
||||
{
|
||||
astring tempstring(tag);
|
||||
tempstring.cat(NESSLOT_PRGROM_REGION_TAG);
|
||||
m_prg = device().machine().memory().region_alloc(tempstring, size, 1, ENDIANNESS_LITTLE)->base();
|
||||
m_prg_size = size;
|
||||
m_prg_chunks = size / 0x4000;
|
||||
if (size % 0x2000)
|
||||
{
|
||||
@ -193,7 +202,7 @@ void device_nes_cart_interface::prg_alloc(size_t size)
|
||||
j += repeat_banks;
|
||||
}
|
||||
|
||||
// check bank map!
|
||||
// check bank map!
|
||||
// for (int i = 0; i < mapsize; i++)
|
||||
// {
|
||||
// printf("bank %3d = %3d\t", i, m_prg_bank_map[i]);
|
||||
@ -201,6 +210,19 @@ void device_nes_cart_interface::prg_alloc(size_t size)
|
||||
// printf("\n");
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void device_nes_cart_interface::vrom_alloc(size_t size, const char *tag)
|
||||
{
|
||||
if (m_vrom == NULL)
|
||||
{
|
||||
astring tempstring(tag);
|
||||
tempstring.cat(NESSLOT_CHRROM_REGION_TAG);
|
||||
m_vrom = device().machine().memory().region_alloc(tempstring, size, 1, ENDIANNESS_LITTLE)->base();
|
||||
m_vrom_size = size;
|
||||
m_vrom_chunks = size / 0x2000;
|
||||
}
|
||||
}
|
||||
|
||||
void device_nes_cart_interface::prgram_alloc(size_t size)
|
||||
@ -208,12 +230,6 @@ void device_nes_cart_interface::prgram_alloc(size_t size)
|
||||
m_prgram.resize(size);
|
||||
}
|
||||
|
||||
void device_nes_cart_interface::vrom_alloc(size_t size)
|
||||
{
|
||||
m_vrom.resize(size);
|
||||
m_vrom_chunks = size / 0x2000;
|
||||
}
|
||||
|
||||
void device_nes_cart_interface::vram_alloc(size_t size)
|
||||
{
|
||||
m_vram.resize(size);
|
||||
@ -669,7 +685,7 @@ void device_nes_cart_interface::pcb_start(running_machine &machine, UINT8 *ciram
|
||||
{
|
||||
if (m_prg_bank_mem[i])
|
||||
{
|
||||
m_prg_bank_mem[i]->configure_entries(0, m_prg.count() / 0x2000, m_prg, 0x2000);
|
||||
m_prg_bank_mem[i]->configure_entries(0, m_prg_size / 0x2000, m_prg, 0x2000);
|
||||
m_prg_bank_mem[i]->set_entry(i);
|
||||
m_prg_bank[i] = i;
|
||||
}
|
||||
@ -732,8 +748,7 @@ nes_cart_slot_device::nes_cart_slot_device(const machine_config &mconfig, const
|
||||
device_slot_interface(mconfig, *this),
|
||||
m_crc_hack(0),
|
||||
m_pcb_id(NO_BOARD),
|
||||
m_must_be_loaded(1),
|
||||
m_empty(TRUE)
|
||||
m_must_be_loaded(1)
|
||||
{
|
||||
}
|
||||
|
||||
@ -770,7 +785,7 @@ void nes_cart_slot_device::device_config_complete()
|
||||
void nes_cart_slot_device::pcb_start(UINT8 *ciram_ptr)
|
||||
{
|
||||
if (m_cart)
|
||||
m_cart->pcb_start(machine(), ciram_ptr, cart_mounted());
|
||||
m_cart->pcb_start(machine(), ciram_ptr, exists());
|
||||
}
|
||||
|
||||
void nes_cart_slot_device::pcb_reset()
|
||||
@ -835,7 +850,6 @@ bool nes_cart_slot_device::call_load()
|
||||
}
|
||||
|
||||
call_load_ines();
|
||||
m_empty = FALSE;
|
||||
}
|
||||
else if ((magic[0] == 'U') && (magic[1] == 'N') && (magic[2] == 'I') && (magic[3] == 'F')) /* If header starts with 'UNIF' it is UNIF */
|
||||
{
|
||||
@ -846,7 +860,6 @@ bool nes_cart_slot_device::call_load()
|
||||
}
|
||||
|
||||
call_load_unif();
|
||||
m_empty = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -855,10 +868,7 @@ bool nes_cart_slot_device::call_load()
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
call_load_pcb();
|
||||
m_empty = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return IMAGE_INIT_PASS;
|
||||
|
@ -176,9 +176,9 @@ public:
|
||||
// hack until disk system is made modern!
|
||||
virtual void disk_flip_side() { }
|
||||
|
||||
void prg_alloc(size_t size);
|
||||
void prg_alloc(size_t size, const char *tag);
|
||||
void vrom_alloc(size_t size, const char *tag);
|
||||
void prgram_alloc(size_t size);
|
||||
void vrom_alloc(size_t size);
|
||||
void vram_alloc(size_t size);
|
||||
void battery_alloc(size_t size);
|
||||
|
||||
@ -204,9 +204,9 @@ public:
|
||||
UINT8* get_battery_base() { return m_battery; }
|
||||
UINT8* get_mapper_sram_base() { return m_mapper_sram; }
|
||||
|
||||
UINT32 get_prg_size() { return m_prg.bytes(); }
|
||||
UINT32 get_prg_size() { return m_prg_size; }
|
||||
UINT32 get_prgram_size() { return m_prgram.bytes(); }
|
||||
UINT32 get_vrom_size() { return m_vrom.bytes(); }
|
||||
UINT32 get_vrom_size() { return m_vrom_size; }
|
||||
UINT32 get_vram_size() { return m_vram.bytes(); }
|
||||
UINT32 get_battery_size() { return m_battery.bytes(); }
|
||||
UINT32 get_mapper_sram_size() { return m_mapper_sram_size; }
|
||||
@ -226,12 +226,14 @@ public:
|
||||
protected:
|
||||
|
||||
// internal state
|
||||
dynamic_buffer m_prg;
|
||||
UINT8 *m_prg;
|
||||
UINT8 *m_vrom;
|
||||
UINT8 *m_ciram;
|
||||
dynamic_buffer m_prgram;
|
||||
dynamic_buffer m_vrom;
|
||||
dynamic_buffer m_vram;
|
||||
dynamic_buffer m_battery;
|
||||
UINT8 *m_ciram;
|
||||
UINT32 m_prg_size;
|
||||
UINT32 m_vrom_size;
|
||||
|
||||
// HACK: to reduce tagmap lookups for PPU-related IRQs, we add a hook to the
|
||||
// main NES CPU here, even if it does not belong to this device.
|
||||
@ -364,7 +366,6 @@ public:
|
||||
const char * get_default_card_unif(UINT8 *ROM, UINT32 len);
|
||||
const char * nes_get_slot(int pcb_id);
|
||||
int nes_get_pcb_id(const char *slot);
|
||||
bool cart_mounted() { return !m_empty; }
|
||||
|
||||
// reading and writing
|
||||
virtual DECLARE_READ8_MEMBER(read_l);
|
||||
@ -396,7 +397,6 @@ public:
|
||||
device_nes_cart_interface* m_cart;
|
||||
int m_pcb_id;
|
||||
bool m_must_be_loaded;
|
||||
bool m_empty;
|
||||
};
|
||||
|
||||
// device type definition
|
||||
@ -407,6 +407,10 @@ extern const device_type NES_CART_SLOT;
|
||||
DEVICE CONFIGURATION MACROS
|
||||
***************************************************************************/
|
||||
|
||||
#define NESSLOT_PRGROM_REGION_TAG ":cart:prg_rom"
|
||||
#define NESSLOT_CHRROM_REGION_TAG ":cart:chr_rom"
|
||||
|
||||
|
||||
#define MCFG_NES_CARTRIDGE_ADD(_tag, _slot_intf, _def_slot) \
|
||||
MCFG_DEVICE_ADD(_tag, NES_CART_SLOT, 0) \
|
||||
MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false)
|
||||
@ -414,6 +418,7 @@ extern const device_type NES_CART_SLOT;
|
||||
#define MCFG_NES_CARTRIDGE_NOT_MANDATORY \
|
||||
static_cast<nes_cart_slot_device *>(device)->set_must_be_loaded(FALSE);
|
||||
|
||||
|
||||
// Hacky configuration to add a slot with fixed disksys interface
|
||||
#define MCFG_DISKSYS_ADD(_tag, _slot_intf, _def_slot) \
|
||||
MCFG_DEVICE_ADD(_tag, NES_CART_SLOT, 0) \
|
||||
|
@ -466,13 +466,13 @@ void nes_cart_slot_device::call_load_unif()
|
||||
// SETUP steps 5/6: allocate pointers for PRG/VROM and load the data!
|
||||
if (prg_size == 0x4000)
|
||||
{
|
||||
m_cart->prg_alloc(0x8000);
|
||||
m_cart->prg_alloc(0x8000, tag());
|
||||
memcpy(m_cart->get_prg_base(), temp_prg, 0x4000);
|
||||
memcpy(m_cart->get_prg_base() + 0x4000, m_cart->get_prg_base(), 0x4000);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_cart->prg_alloc(prg_size);
|
||||
m_cart->prg_alloc(prg_size, tag());
|
||||
memcpy(m_cart->get_prg_base(), temp_prg, prg_size);
|
||||
}
|
||||
|
||||
@ -481,7 +481,7 @@ void nes_cart_slot_device::call_load_unif()
|
||||
|
||||
if (vrom_size)
|
||||
{
|
||||
m_cart->vrom_alloc(vrom_size);
|
||||
m_cart->vrom_alloc(vrom_size, tag());
|
||||
memcpy(m_cart->get_vrom_base(), temp_chr, vrom_size);
|
||||
}
|
||||
|
||||
|
@ -555,7 +555,7 @@ READ8_MEMBER(nes_sunsoft_fme7_device::read_m)
|
||||
LOG_MMC(("Sunsoft FME7 read_m, offset: %04x\n", offset));
|
||||
|
||||
if (!(m_wram_bank & 0x40)) // is PRG ROM
|
||||
return m_prg[((bank * 0x2000) + offset) & (m_prg.count() - 1)];
|
||||
return m_prg[((bank * 0x2000) + offset) & (m_prg_size - 1)];
|
||||
else if (m_wram_bank & 0x80) // is PRG RAM
|
||||
{
|
||||
if (m_battery)
|
||||
|
@ -39,7 +39,7 @@ UINT32 nes_state::screen_update_nes(screen_device &screen, bitmap_ind16 &bitmap,
|
||||
// if this is a disk system game, check for the flip-disk key
|
||||
if (m_cartslot &&
|
||||
(m_cartslot->get_pcb_id() == STD_DISKSYS // first scenario = disksys in m_cartslot (= famicom)
|
||||
|| !m_cartslot->cart_mounted())) // second scenario = disk via fixed internal option (= fds)
|
||||
|| !m_cartslot->exists())) // second scenario = disk via fixed internal option (= fds)
|
||||
{
|
||||
// latch this input so it doesn't go at warp speed
|
||||
if ((m_io_disksel->read_safe(0) & 0x01) && (!m_last_frame_flip))
|
||||
@ -60,7 +60,7 @@ UINT32 nes_state::screen_update_famitwin(screen_device &screen, bitmap_ind16 &bi
|
||||
// render the ppu
|
||||
m_ppu->render(bitmap, 0, 0, 0, 0);
|
||||
|
||||
if (m_cartslot2 && !m_cartslot2->cart_mounted())
|
||||
if (m_cartslot2 && !m_cartslot2->exists())
|
||||
{
|
||||
// latch this input so it doesn't go at warp speed
|
||||
if ((m_io_disksel->read_safe(0) & 0x01) && (!m_last_frame_flip))
|
||||
|
Loading…
Reference in New Issue
Block a user