mirror of
https://github.com/holub/mame
synced 2025-04-22 00:11:58 +03:00
(MESS) md_slot.c: let's try to load carts in a rom region rather than in a dynamic buffer.
This hopefully allows to search for ROM cheats again and fixes bug MT5488. nw.
This commit is contained in:
parent
5496f9b617
commit
38f2a4f376
@ -62,7 +62,9 @@ const device_type COPERA_CART_SLOT = &device_creator<copera_cart_slot_device>;
|
||||
//-------------------------------------------------
|
||||
|
||||
device_md_cart_interface::device_md_cart_interface(const machine_config &mconfig, device_t &device)
|
||||
: device_slot_card_interface(mconfig, device)
|
||||
: device_slot_card_interface(mconfig, device),
|
||||
m_rom(NULL),
|
||||
m_rom_size(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -79,10 +81,14 @@ device_md_cart_interface::~device_md_cart_interface()
|
||||
// rom_alloc - alloc the space for the cart
|
||||
//-------------------------------------------------
|
||||
|
||||
void device_md_cart_interface::rom_alloc(size_t size)
|
||||
void device_md_cart_interface::rom_alloc(size_t size, const char *tag)
|
||||
{
|
||||
if (m_rom == NULL)
|
||||
m_rom.resize(size/sizeof(UINT16));
|
||||
{
|
||||
astring tempstring(tag);
|
||||
m_rom = (UINT16 *)device().machine().memory().region_alloc(tempstring, size, 2, ENDIANNESS_LITTLE)->base();
|
||||
m_rom_size = size;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -367,9 +373,11 @@ int base_md_cart_slot_device::load_list()
|
||||
// if cart size is not (2^n * 64K), the system will see anyway that size so we need to alloc a bit more space
|
||||
length = m_cart->get_padded_size(length);
|
||||
|
||||
m_cart->rom_alloc(length);
|
||||
astring cart_string(tag());
|
||||
cart_string.cat(":cart:rom");
|
||||
m_cart->rom_alloc(length, cart_string.cstr());
|
||||
ROM = m_cart->get_rom_base();
|
||||
memcpy(ROM, get_software_region("rom"), get_software_region_length("rom"));
|
||||
memcpy((UINT8 *)ROM, get_software_region("rom"), get_software_region_length("rom"));
|
||||
|
||||
// if we allocated a ROM larger that the file (e.g. due to uneven cart size), set remaining space to 0xff
|
||||
if (length > get_software_region_length("rom"))
|
||||
@ -479,7 +487,9 @@ int base_md_cart_slot_device::load_nonlist()
|
||||
// if cart size is not (2^n * 64K), the system will see anyway that size so we need to alloc a bit more space
|
||||
len = m_cart->get_padded_size(tmplen - offset);
|
||||
// this contains an hack for SSF2: its current bankswitch code needs larger rom space to work
|
||||
m_cart->rom_alloc((len == 0x500000) ? 0x900000 : len);
|
||||
astring cart_string(tag());
|
||||
cart_string.cat(":cart:rom");
|
||||
m_cart->rom_alloc((len == 0x500000) ? 0x900000 : len, cart_string.cstr());
|
||||
|
||||
|
||||
// STEP 3: copy the game data in the appropriate way
|
||||
@ -602,7 +612,7 @@ void base_md_cart_slot_device::setup_nvram()
|
||||
m_cart->m_nvram_end += 1;
|
||||
|
||||
m_cart->nvram_alloc(m_cart->m_nvram_end - m_cart->m_nvram_start + 1);
|
||||
if (m_cart->m_rom.bytes() <= m_cart->m_nvram_start)
|
||||
if (m_cart->m_rom_size <= m_cart->m_nvram_start)
|
||||
m_cart->m_nvram_active = 1;
|
||||
m_cart->m_nvram_handlers_installed = 1;
|
||||
// don't trust too much header?
|
||||
@ -615,7 +625,7 @@ void base_md_cart_slot_device::setup_nvram()
|
||||
logerror("No SRAM detected from header, using fallback SRAM in case this is a broken header\n");
|
||||
|
||||
m_cart->nvram_alloc(m_cart->m_nvram_end - m_cart->m_nvram_start + 1);
|
||||
if (m_cart->m_rom.bytes() <= m_cart->m_nvram_start)
|
||||
if (m_cart->m_rom_size <= m_cart->m_nvram_start)
|
||||
m_cart->m_nvram_active = 1;
|
||||
break;
|
||||
|
||||
@ -624,7 +634,7 @@ void base_md_cart_slot_device::setup_nvram()
|
||||
m_cart->m_nvram_start = 0x200000;
|
||||
m_cart->m_nvram_end = m_cart->m_nvram_start + get_software_region_length("sram") - 1;
|
||||
m_cart->nvram_alloc(m_cart->m_nvram_end - m_cart->m_nvram_start + 1);
|
||||
if (m_cart->m_rom.bytes() <= m_cart->m_nvram_start)
|
||||
if (m_cart->m_rom_size <= m_cart->m_nvram_start)
|
||||
m_cart->m_nvram_active = 1;
|
||||
m_cart->m_nvram_handlers_installed = 1;
|
||||
break;
|
||||
@ -989,8 +999,8 @@ void base_md_cart_slot_device::file_logging(UINT8 *ROM8, UINT32 rom_len, UINT32
|
||||
astring ctrl(""), reg("");
|
||||
|
||||
// LOG FILE DETAILS
|
||||
logerror("FILE DETAILS\n" );
|
||||
logerror("============\n" );
|
||||
logerror("FILE DETAILS\n");
|
||||
logerror("============\n");
|
||||
logerror("Name: %s\n", basename());
|
||||
logerror("File Size: 0x%" I64FMT "x\n", (software_entry() == NULL) ? length() : get_software_region_length("rom"));
|
||||
logerror("Detected type: %s\n", md_get_slot(m_type));
|
||||
@ -1062,8 +1072,8 @@ void base_md_cart_slot_device::file_logging(UINT8 *ROM8, UINT32 rom_len, UINT32
|
||||
csum &= 0xffff;
|
||||
}
|
||||
|
||||
logerror("INTERNAL HEADER\n" );
|
||||
logerror("===============\n" );
|
||||
logerror("INTERNAL HEADER\n");
|
||||
logerror("===============\n");
|
||||
logerror("Console: %.16s\n", console);
|
||||
logerror("Copyright String: %.16s\n", copyright);
|
||||
logerror(" - Manufacturer: %.4s\n", copyright + 3); // TODO: convert code to manufacturer name!
|
||||
|
@ -107,11 +107,11 @@ public:
|
||||
/* this probably should do more, like make Genesis V2 'die' if the SEGA string is not written promptly */
|
||||
virtual DECLARE_WRITE16_MEMBER(write_tmss_bank) { logerror("Write to TMSS bank: offset %x data %x\n", 0xa14000 + (offset << 1), data); };
|
||||
|
||||
virtual void rom_alloc(size_t size);
|
||||
virtual void rom_alloc(size_t size, const char *tag);
|
||||
virtual void nvram_alloc(size_t size);
|
||||
virtual UINT16* get_rom_base() { return m_rom; };
|
||||
virtual UINT16* get_nvram_base() { return m_nvram; };
|
||||
virtual UINT32 get_rom_size() { return m_rom.bytes(); };
|
||||
virtual UINT32 get_rom_size() { return m_rom_size; };
|
||||
virtual UINT32 get_nvram_size() { return m_nvram.bytes(); };
|
||||
virtual void set_bank_to_rom(const char *banktag, UINT32 offset) {};
|
||||
|
||||
@ -127,7 +127,8 @@ public:
|
||||
int m_nvram_handlers_installed;
|
||||
|
||||
// internal state
|
||||
dynamic_array<UINT16> m_rom;
|
||||
UINT16 *m_rom;
|
||||
UINT32 m_rom_size;
|
||||
dynamic_array<UINT16> m_nvram;
|
||||
|
||||
UINT8 rom_bank_map[128]; // 64K chunks of rom
|
||||
|
@ -549,7 +549,7 @@ READ16_MEMBER(md_rom_cm2in1_device::read)
|
||||
READ16_MEMBER(md_rom_mcpirate_device::read)
|
||||
{
|
||||
if (offset < 0x400000/2)
|
||||
return m_rom[(((m_bank * 0x10000) + (offset << 1)) & (m_rom.bytes() - 1))/2];
|
||||
return m_rom[(((m_bank * 0x10000) + (offset << 1)) & (m_rom_size - 1))/2];
|
||||
else
|
||||
return read(space, offset - 0x400000/2, 0xffff);
|
||||
}
|
||||
@ -795,7 +795,7 @@ WRITE16_MEMBER(md_rom_lion2_device::write)
|
||||
LION KING 3
|
||||
-------------------------------------------------*/
|
||||
|
||||
#define MD_LION3_ADDR(a) (((offset << 1) | (m_bank << 15)) & (m_rom.bytes() - 1))/2
|
||||
#define MD_LION3_ADDR(a) (((offset << 1) | (m_bank << 15)) & (m_rom_size - 1))/2
|
||||
|
||||
READ16_MEMBER(md_rom_lion3_device::read)
|
||||
{
|
||||
@ -926,7 +926,7 @@ READ16_MEMBER(md_rom_soulb_device::read)
|
||||
POKEMON STADIUM / KAIJU
|
||||
-------------------------------------------------*/
|
||||
|
||||
#define MD_POKESTAD_ADDR(a) (((offset << 1) | (m_bank << 15)) & (m_rom.bytes() - 1))/2
|
||||
#define MD_POKESTAD_ADDR(a) (((offset << 1) | (m_bank << 15)) & (m_rom_size - 1))/2
|
||||
|
||||
READ16_MEMBER(md_rom_pokestad_device::read)
|
||||
{
|
||||
@ -1308,7 +1308,7 @@ WRITE16_MEMBER(md_rom_topf_device::write)
|
||||
|
||||
READ16_MEMBER(md_rom_radica_device::read)
|
||||
{
|
||||
return m_rom[(((m_bank * 0x10000) + (offset << 1)) & (m_rom.bytes() - 1))/2];
|
||||
return m_rom[(((m_bank * 0x10000) + (offset << 1)) & (m_rom_size - 1))/2];
|
||||
}
|
||||
|
||||
READ16_MEMBER(md_rom_radica_device::read_a13)
|
||||
|
Loading…
Reference in New Issue
Block a user