summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2022-09-13 17:29:24 +1000
committer Vas Crabb <vas@vastheman.com>2022-09-13 17:29:24 +1000
commit511e01c1161ea9f14d0468c2a13b0e0fb630bdb4 (patch)
treebeb7d552282d5ecbd80445fb4903e9172fb9bc8c
parentf2831873715d4605c50d1f4114e82ecbd612ce23 (diff)
bus/gameboy/mbc.cpp: Fixed up some details.
* MBC5 checks all the bits of the RAM enable register. Not sure if any games actually depend on this. * Changed MBC3 device to support an additional RAM bank output so it can run the one MBC30 game (Pocket Monsters Crystal).
-rw-r--r--src/devices/bus/gameboy/huc3.cpp4
-rw-r--r--src/devices/bus/gameboy/mbc.cpp36
2 files changed, 29 insertions, 11 deletions
diff --git a/src/devices/bus/gameboy/huc3.cpp b/src/devices/bus/gameboy/huc3.cpp
index c91db517a49..1ab47ce6da0 100644
--- a/src/devices/bus/gameboy/huc3.cpp
+++ b/src/devices/bus/gameboy/huc3.cpp
@@ -76,8 +76,8 @@
0x6 - Execute extended command (selector from bits 3-0 of 0xB)
The games use four of the sixteen possible extended commands:
- 0x0 - Atomically read real-time clock to registers 0-7
- 0x1 - Atomically write real-time clock from registers 0-7
+ 0x0 - Atomically read real-time clock to registers 0-6
+ 0x1 - Atomically write real-time clock from registers 0-6
0x2 - Some kind of handshake/status request - sets result to 0x1
0xe - Sent twice to trigger melody generator
diff --git a/src/devices/bus/gameboy/mbc.cpp b/src/devices/bus/gameboy/mbc.cpp
index a34b215052a..4b705e1cc63 100644
--- a/src/devices/bus/gameboy/mbc.cpp
+++ b/src/devices/bus/gameboy/mbc.cpp
@@ -75,6 +75,9 @@
TODO:
* What does MBC3 do with the RAM bank outputs when RTC is selected?
* How do MBC3 invalid second/minute/hour values roll over?
+ * For convenience, MBC3 and MBC30 are emulated as one device for now.
+ - MBC3 only has 2 RAM bank outputs, but it will allow 3 like MBC30 here.
+ - MBC30 supposedly has 8 ROM bank outputs, but the one game using it only needs 7.
* MBC5 logo spoofing class implements several strategies. It's likely not all carts using it use all
the strategies. Strategies implemented by each cartridge should be identified.
* Digimon 2 mapper doesn't work
@@ -177,11 +180,6 @@ protected:
m_view_ram.disable();
}
- void enable_ram(u8 data)
- {
- set_ram_enable(0x0a == (data & 0x0f));
- }
-
void bank_switch_coarse(u8 data)
{
set_bank_rom_coarse(data & m_bank_lines[1]);
@@ -253,6 +251,11 @@ protected:
return rom_mbc_device_base::install_memory(message, 4, 9);
}
+ void enable_ram(u8 data)
+ {
+ set_ram_enable(0x0a == data);
+ }
+
void bank_switch_fine_low(u8 data)
{
set_bank_rom_fine((bank_rom_fine() & 0x0100) | u16(data));
@@ -474,6 +477,11 @@ protected:
}
private:
+ void enable_ram(u8 data)
+ {
+ set_ram_enable(0x0a == (data & 0x0f));
+ }
+
void bank_switch_fine(u8 data)
{
data &= 0x1f;
@@ -676,7 +684,7 @@ public:
}
// set up ROM and RAM
- if (!install_memory(message, 2, 7))
+ if (!install_memory(message, 3, 7))
return image_init_result::FAIL;
// install bank switching handlers
@@ -701,6 +709,13 @@ public:
0xa000, 0xbfff,
write8smo_delegate(*this, FUNC(mbc3_device::write_rtc)));
+ // if real-time clock crystal is present, start it ticking
+ if (m_has_rtc_xtal)
+ {
+ logerror("Real-time clock crystal present, starting timer\n");
+ m_timer_rtc->adjust(attotime(1, 0), 0, attotime(1, 0));
+ }
+
// all good
return image_init_result::PASS;
};
@@ -716,8 +731,6 @@ protected:
save_item(NAME(m_rtc_enable));
save_item(NAME(m_rtc_select));
save_item(NAME(m_rtc_latch));
-
- m_timer_rtc->adjust(attotime(1, 0), 0, attotime(1, 0));
}
virtual void device_reset() override ATTR_COLD
@@ -1747,6 +1760,11 @@ protected:
}
private:
+ void enable_ram(u8 data)
+ {
+ set_ram_enable(0x0a == (data & 0x0f));
+ }
+
void bank_switch_fine(u8 data)
{
data >>= 1;
@@ -1761,7 +1779,7 @@ private:
// device type definition
DEFINE_DEVICE_TYPE_PRIVATE(GB_ROM_MBC1, device_gb_cart_interface, bus::gameboy::mbc1_device, "gb_rom_mbc1", "Game Boy MBC1 Cartridge")
-DEFINE_DEVICE_TYPE_PRIVATE(GB_ROM_MBC3, device_gb_cart_interface, bus::gameboy::mbc3_device, "gb_rom_mbc3", "Game Boy MBC3 Cartridge")
+DEFINE_DEVICE_TYPE_PRIVATE(GB_ROM_MBC3, device_gb_cart_interface, bus::gameboy::mbc3_device, "gb_rom_mbc3", "Game Boy MBC3/MBC30 Cartridge")
DEFINE_DEVICE_TYPE_PRIVATE(GB_ROM_MBC5, device_gb_cart_interface, bus::gameboy::mbc5_device, "gb_rom_mbc5", "Game Boy MBC5 Cartridge")
DEFINE_DEVICE_TYPE_PRIVATE(GB_ROM_SINTAX, device_gb_cart_interface, bus::gameboy::sintax_device, "gb_rom_sintax", "Game Boy Sintax MBC5 Cartridge")
DEFINE_DEVICE_TYPE_PRIVATE(GB_ROM_CHONGWU, device_gb_cart_interface, bus::gameboy::chongwu_device, "gb_rom_chongwu", "Game Boy Chongwu Xiao Jingling Pokemon Pikecho Cartridge")