From 670a52740a7814b4ba15b98ed0b838fffcdb3466 Mon Sep 17 00:00:00 2001
From: 0kmg <9137159+0kmg@users.noreply.github.com>
Date: Wed, 6 Oct 2021 18:20:35 -0800
Subject: [PATCH] bus/nes: Fixed loading and bank locking for EH8813A boards.
(#8666)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
New working software list additions (nes.xml)
-----------------------------------
1996 Yīngyǔ CAI 3 in 1 (China) [taizou]
Xiǎoxuéshēng Shùxué CAI (China) [MLX]
---
hash/nes.xml | 37 ++++++++++++++++++++
src/devices/bus/nes/pirate.cpp | 62 +++++++++++++++-------------------
src/devices/bus/nes/pirate.h | 10 +++---
3 files changed, 71 insertions(+), 38 deletions(-)
diff --git a/hash/nes.xml b/hash/nes.xml
index 2a5c06e640e..d5202ffbffb 100644
--- a/hash/nes.xml
+++ b/hash/nes.xml
@@ -55456,6 +55456,43 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx
+
+ Xiǎoxuéshēng Shùxué CAI (China)
+ 1996
+ Waixing
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1996 Yīngyǔ CAI 3 in 1 (China)
+ 1996
+ Waixing
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Zheng Ba ShiJi (Chi, Decrypted WXN)
19??
diff --git a/src/devices/bus/nes/pirate.cpp b/src/devices/bus/nes/pirate.cpp
index fdc48fdc66b..ddfc93ae258 100644
--- a/src/devices/bus/nes/pirate.cpp
+++ b/src/devices/bus/nes/pirate.cpp
@@ -127,8 +127,8 @@ nes_cityfight_device::nes_cityfight_device(const machine_config &mconfig, const
{
}
-nes_eh8813a_device::nes_eh8813a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : nes_nrom_device(mconfig, NES_EH8813A, tag, owner, clock), m_dipsetting(0), m_latch(0)
+nes_eh8813a_device::nes_eh8813a_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
+ : nes_nrom_device(mconfig, NES_EH8813A, tag, owner, clock), m_jumper(0), m_latch(0), m_reg(0)
{
}
@@ -402,20 +402,19 @@ void nes_cityfight_device::pcb_reset()
void nes_eh8813a_device::device_start()
{
common_start();
- save_item(NAME(m_dipsetting));
+ save_item(NAME(m_jumper));
save_item(NAME(m_latch));
+ save_item(NAME(m_reg));
}
void nes_eh8813a_device::pcb_reset()
{
- m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM;
- prg16_89ab(0);
- prg16_89ab(m_prg_chunks - 1);
- chr8(0, m_chr_source);
- set_nt_mirroring(PPU_MIRROR_VERT);
+ prg32(0);
+ chr8(0, CHRROM);
- m_dipsetting = 0; // no means to adjust cart DIPs - unimplemented
+ m_jumper = 0;
m_latch = 0;
+ m_reg = 0;
}
@@ -1238,46 +1237,41 @@ void nes_cityfight_device::write_h(offs_t offset, uint8_t data)
UNL-EH8813A
- Games: Dr. Mario II
-
- Board is used in multicarts other than this? "BY ES"
- in pause menu suggests this may be by Waixing. Title
- menus change with DIP settings (currently unimplemented),
- but it is unclear if PCB has switch or solder pads or...?
+ Games: Dr. Mario II, 1996 English CAI 3 in 1,
+ Elementary School Math CAI
NES 2.0: mapper 519
- In MAME: Preliminary supported.
+ In MAME: Supported.
-------------------------------------------------*/
-void nes_eh8813a_device::write_h(offs_t offset, uint8_t data)
+void nes_eh8813a_device::write_h(offs_t offset, u8 data)
{
LOG_MMC(("unl_eh8813a write_h, offset: %04x, data: %02x\n", offset, data));
- if (BIT(offset, 8))
- return;
-
- chr8(data & 0x7f, m_chr_source);
- set_nt_mirroring(BIT(data, 7) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
-
- uint8_t bank = offset & 0x3f;
- if (BIT(offset, 7))
+ if (!BIT(m_latch, 8))
{
- prg16_89ab(bank);
- prg16_cdef(bank);
- }
- else
- prg32(bank >> 1);
+ m_latch = offset;
+ m_reg = data;
- m_latch = BIT(offset, 6);
+ u8 bank = m_latch & 0x3f;
+ u8 mode = !BIT(m_latch, 7);
+ prg16_89ab(bank & ~mode);
+ prg16_cdef(bank | mode);
+
+ set_nt_mirroring(BIT(m_reg, 7) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
+ }
+
+ chr8((m_reg & 0x7c) | (data & 0x03), CHRROM);
}
-uint8_t nes_eh8813a_device::read_h(offs_t offset)
+u8 nes_eh8813a_device::read_h(offs_t offset)
{
LOG_MMC(("unl_eh8813a read_h, offset: %04x\n", offset));
- if (m_latch)
- offset = (offset & 0xfff0) | m_dipsetting;
+
+ if (BIT(m_latch, 6))
+ offset = (offset & ~0x0f) | m_jumper; // TODO: jumper setting that controls which menu appears is 0 for now
return hi_access_rom(offset);
}
diff --git a/src/devices/bus/nes/pirate.h b/src/devices/bus/nes/pirate.h
index 4b0e1f1ae61..9f54fc778ca 100644
--- a/src/devices/bus/nes/pirate.h
+++ b/src/devices/bus/nes/pirate.h
@@ -349,10 +349,10 @@ class nes_eh8813a_device : public nes_nrom_device
{
public:
// construction/destruction
- nes_eh8813a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+ nes_eh8813a_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
- virtual uint8_t read_h(offs_t offset) override;
- virtual void write_h(offs_t offset, uint8_t data) override;
+ virtual u8 read_h(offs_t offset) override;
+ virtual void write_h(offs_t offset, u8 data) override;
virtual void pcb_reset() override;
@@ -361,7 +361,9 @@ protected:
virtual void device_start() override;
private:
- uint8_t m_dipsetting, m_latch;
+ u8 m_jumper;
+ u16 m_latch;
+ u8 m_reg;
};