From 5477d4ded39f81ec1be32ac20568552dc05650df Mon Sep 17 00:00:00 2001 From: Fabio Priuli Date: Thu, 23 May 2013 12:54:27 +0000 Subject: [PATCH] (MESS) sms/gamegear: updated the systems to rely on xml only for RAM/NVRAM when loading from softlist. [Fabio Priuli] from fullpath it still allocates 32k for every game, and if the game enables RAM the content is saved at exit. --- hash/gamegear.xml | 127 +++++++++++++++++++++++++++++++++- hash/sms.xml | 81 +++++++++++++++++++++- src/mess/machine/sega8_rom.c | 6 +- src/mess/machine/sega8_slot.c | 52 ++++++++++---- src/mess/machine/sega8_slot.h | 8 +++ 5 files changed, 255 insertions(+), 19 deletions(-) diff --git a/hash/gamegear.xml b/hash/gamegear.xml index 7c5036e08e8..1323951a0ca 100644 --- a/hash/gamegear.xml +++ b/hash/gamegear.xml @@ -416,9 +416,13 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + + @@ -1873,9 +1877,13 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + + @@ -1931,9 +1939,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas Sega + + + @@ -1942,9 +1953,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas 1992 Sega + + + @@ -1962,6 +1976,8 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + @@ -2382,6 +2398,8 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + @@ -2393,9 +2411,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + @@ -2981,9 +3002,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + @@ -3341,9 +3365,13 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + + @@ -3654,9 +3682,13 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + + @@ -4060,9 +4092,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + @@ -4098,9 +4133,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + @@ -4112,9 +4150,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + @@ -4131,9 +4172,13 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + + @@ -4145,9 +4190,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + @@ -4159,9 +4207,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + @@ -4178,9 +4229,13 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + + @@ -4197,9 +4252,13 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + + @@ -4211,9 +4270,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + @@ -4313,9 +4375,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + @@ -4327,9 +4392,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + @@ -4490,9 +4558,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + @@ -4622,9 +4693,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + @@ -5063,9 +5137,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + @@ -5793,9 +5870,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + @@ -5885,9 +5965,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + @@ -6504,9 +6587,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + @@ -6619,9 +6705,13 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + + @@ -6656,9 +6746,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + @@ -6726,9 +6819,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + @@ -6740,9 +6836,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + @@ -6752,9 +6851,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas Sega + + + @@ -6773,9 +6875,13 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + + @@ -6784,9 +6890,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas 1994 Sega + + + @@ -6795,9 +6904,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas 1994 Sega + + + @@ -6806,9 +6918,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas 1994 Sega + + + @@ -6817,9 +6932,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas 1994 Sega + + + @@ -8433,9 +8551,12 @@ A few games have been listed as rumored, but they might very well be fake (pleas + + + @@ -8534,10 +8655,14 @@ A few games have been listed as rumored, but they might very well be fake (pleas - + + + + + diff --git a/hash/sms.xml b/hash/sms.xml index e814a523096..4c14574ed51 100644 --- a/hash/sms.xml +++ b/hash/sms.xml @@ -1668,6 +1668,8 @@ + + @@ -1718,9 +1720,12 @@ + + + @@ -1729,9 +1734,12 @@ 1987 Sega + + + @@ -2314,6 +2322,8 @@ + + @@ -2560,10 +2570,13 @@ - + + + + @@ -2727,9 +2740,13 @@ + + + + @@ -2738,9 +2755,12 @@ 1990 Sega + + + @@ -3023,9 +3043,12 @@ + + + @@ -3950,9 +3973,12 @@ Sega + + + @@ -3961,9 +3987,12 @@ 1987 Sega + + + @@ -4037,9 +4066,12 @@ 1988 Sega + + + @@ -4049,9 +4081,12 @@ Sega + + + @@ -4060,9 +4095,12 @@ 1988 Sega + + + @@ -4167,9 +4205,12 @@ 1989 Sega + + + @@ -4478,9 +4519,13 @@ + + + + @@ -4668,9 +4713,13 @@ + + + + @@ -4679,9 +4728,12 @@ 1987 Sega + + + @@ -4691,9 +4743,12 @@ Tec Toy + + + @@ -4709,9 +4764,13 @@ + + + + @@ -4722,9 +4781,12 @@ 1994 Sega + + + @@ -4734,9 +4796,12 @@ Sega + + + @@ -6628,9 +6693,13 @@ + + + + @@ -6639,9 +6708,12 @@ 1990 Sega + + + @@ -7161,9 +7233,12 @@ + + + @@ -7176,9 +7251,13 @@ + + + + diff --git a/src/mess/machine/sega8_rom.c b/src/mess/machine/sega8_rom.c index 82f829fe656..efe568453d5 100644 --- a/src/mess/machine/sega8_rom.c +++ b/src/mess/machine/sega8_rom.c @@ -291,8 +291,10 @@ WRITE8_MEMBER(sega8_rom_device::write_mapper) case 0: if (data & 0x08) { - // hack: if the RAM is ever enabled by the game, then we save it at exit... - has_battery = 1; + // hack: if we were loading from fullpath (hence allowing m_late_battery_enable to be true) + // and the RAM is ever enabled by the game, then we save it at exit... + if (m_late_battery_enable) + has_battery = 1; m_ram_enabled = 1; m_ram_base = (data & 0x04) >> 2; } diff --git a/src/mess/machine/sega8_slot.c b/src/mess/machine/sega8_slot.c index e9ce9f6276c..90072bd0763 100644 --- a/src/mess/machine/sega8_slot.c +++ b/src/mess/machine/sega8_slot.c @@ -55,6 +55,7 @@ device_sega8_cart_interface::device_sega8_cart_interface(const machine_config &m m_ram_size(0), m_rom_page_count(0), has_battery(FALSE), + m_late_battery_enable(FALSE), m_lphaser_xoffs(0), m_sms_mode(0) { @@ -267,6 +268,38 @@ void sega8_cart_slot_device::set_lphaser_xoffset( UINT8 *rom, int size ) m_cart->set_lphaser_xoffs(xoff); } +void sega8_cart_slot_device::setup_ram() +{ + if (software_entry() == NULL) + { + // from fullpath we have no way to know exactly if there was RAM, how much RAM was in the cart and if there was a battery + // so we always alloc 32KB and we save its content only if the game enable the RAM (unless it's Codemasters mapper...) + + if (m_type != SEGA8_CODEMASTERS) + { + m_cart->set_late_battery(TRUE); + m_cart->ram_alloc(machine(), 0x08000); + } + else + { + // Codemasters cart can have 64KB of RAM (Ernie Els Golf) and no battery + m_cart->ram_alloc(machine(), 0x10000); + m_cart->set_has_battery(FALSE); + } + } + else + { + // from softlist we rely on the xml to only allocate the correct amount of RAM and to save it only if a battery was present + const char *battery = get_feature("battery"); + m_cart->set_late_battery(FALSE); + + if (get_software_region_length("ram")) + m_cart->ram_alloc(machine(), get_software_region_length("ram")); + + if (battery && !strcmp(battery, "yes")) + m_cart->set_has_battery(TRUE); + } +} bool sega8_cart_slot_device::call_load() { @@ -312,22 +345,10 @@ bool sega8_cart_slot_device::call_load() m_type = sega8_get_pcb_id(get_feature("slot") ? get_feature("slot") : "rom"); else m_type = get_cart_type(ROM, len); - - - if (m_type == SEGA8_CODEMASTERS) - { - m_cart->ram_alloc(machine(), 0x10000); - m_cart->set_has_battery(FALSE); - } - else - { - // for now - m_cart->ram_alloc(machine(), 0x08000); - //m_cart->set_has_battery(TRUE); - } set_lphaser_xoffset(ROM, len); + setup_ram(); // Check for gamegear cartridges with PIN 42 set to SMS mode if (software_entry() != NULL) @@ -337,8 +358,9 @@ bool sega8_cart_slot_device::call_load() m_cart->set_sms_mode(1); } - // for now we always attempt to load a battery, but we only save it if ram is actually accessed - if (m_cart->get_ram_size() /*&& m_cart->get_has_battery()*/) + // when loading from fullpath m_late_battery_enable can be TRUE and in that case + // we attempt to load a battery because the game might have it! + if (m_cart->get_ram_size() && (m_cart->get_has_battery() || m_cart->get_late_battery())) battery_load(m_cart->get_ram_base(), m_cart->get_ram_size(), 0x00); //printf("Type: %s\n", sega8_get_slot(type)); diff --git a/src/mess/machine/sega8_slot.h b/src/mess/machine/sega8_slot.h index 20dd36d3db2..173cdb8829c 100644 --- a/src/mess/machine/sega8_slot.h +++ b/src/mess/machine/sega8_slot.h @@ -47,6 +47,8 @@ public: void set_has_battery(bool val) { has_battery = val; } bool get_has_battery() { return has_battery; } + void set_late_battery(bool val) { m_late_battery_enable = val; } + bool get_late_battery() { return m_late_battery_enable; } void set_lphaser_xoffs(int val) { m_lphaser_xoffs = val; } int get_lphaser_xoffs() { return m_lphaser_xoffs; } void set_sms_mode(int val) { m_sms_mode = val; } @@ -70,6 +72,11 @@ public: int m_rom_page_count; bool has_battery; + + // we use this variable for fullpath loading only: in this case, RAM is always allocated, + // but we set has_battery only if RAM is actually enabled during game... + bool m_late_battery_enable; + int m_lphaser_xoffs; int m_sms_mode; }; @@ -99,6 +106,7 @@ public: int get_type() { return m_type; } int get_cart_type(UINT8 *ROM, UINT32 len); + void setup_ram(); void internal_header_logging(UINT8 *ROM, UINT32 len, UINT32 nvram_len); int verify_cart(UINT8 *magic, int size); void set_lphaser_xoffset(UINT8 *rom, int size);