bus/nes: Fixed non-working Whirlwind LE10 SMB2 FDS conversion. (#8361)

Software list items promoted to working (nes.xml)
---------------------------------------
Super Mario Bros. 2 (LE10)
This commit is contained in:
0kmg 2021-07-26 09:48:15 -08:00 committed by GitHub
parent bf957bc417
commit 80fd0a8548
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 81 additions and 20 deletions

View File

@ -67226,8 +67226,8 @@ Also notice that VRAM & WRAM are probably incorrect for some of these sets, at t
</part>
</software>
<!-- Whirlwind Manu has at least two version: LE10 and LF36. This earlier version apparently hangs at the end of world 4-4 on real hardware. -->
<software name="smb2fdse" cloneof="smb2fds" supported="no">
<!-- Whirlwind Manu has at least two versions: LE10 and LF36. This earlier version has a broken status bar that scrolls with the game. It also crashes at the end of world 4-4 on real hardware (and in MAME). -->
<software name="smb2fdse" cloneof="smb2fds">
<description>Super Mario Bros. 2 (LE10)</description>
<year>19??</year>
<publisher>Whirlwind Manu</publisher>

View File

@ -117,8 +117,8 @@ nes_0353_device::nes_0353_device(const machine_config &mconfig, const char *tag,
{
}
nes_09034a_device::nes_09034a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: nes_nrom_device(mconfig, NES_09034A, tag, owner, clock), m_reg(0)
nes_09034a_device::nes_09034a_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: nes_nrom_device(mconfig, NES_09034A, tag, owner, clock), m_irq_count(0), m_irq_enable(0), m_reg(0), irq_timer(nullptr)
{
}
@ -434,6 +434,11 @@ void nes_0353_device::pcb_reset()
void nes_09034a_device::device_start()
{
common_start();
irq_timer = timer_alloc(TIMER_IRQ);
irq_timer->adjust(attotime::zero, 0, clocks_to_attotime(1));
save_item(NAME(m_irq_enable));
save_item(NAME(m_irq_count));
save_item(NAME(m_reg));
}
@ -442,6 +447,9 @@ void nes_09034a_device::pcb_reset()
m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM;
prg32(0);
chr8(0, m_chr_source);
m_irq_enable = 0;
m_irq_count = 0;
m_reg = 0;
}
@ -1304,30 +1312,76 @@ void nes_0353_device::write_h(offs_t offset, u8 data)
(UNL-)09-034A
Games: Zanac FDS conversion with two PRG chips and
no CHRROM and Volleyball FDS conversion with two PRG
chips and CHRROM.
Originally dumps were marked as UNL-SMB2J pcb
no CHRROM, and SMB2 and Volleyball FDS conversions
with two PRG chips and CHRROM. Originally dumps
were marked as UNL-SMB2J PCB.
Only SMB2 uses the IRQ and it has been documented as
being broken on real hardware. Most notably the status
bar scrolls with the rest of the screen and the game
completely crashes between the "our princess" scene of
world 4-4 and the beginning of world 5-1. How the IRQ
functions is to be confirmed but it likely uses a 12-bit
counter just like the other SMB2 bootlegs. That is how
we presently emulate it here.
NES 2.0: mapper 304
In MAME: Partially supported. Need to emulate IRQ
(needed by smb2 conversion?)
In MAME: Supported.
-------------------------------------------------*/
void nes_09034a_device::write_ex(offs_t offset, uint8_t data)
void nes_09034a_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
if (id == TIMER_IRQ)
{
if (m_irq_enable)
{
m_irq_count = (m_irq_count + 1) & 0x0fff;
if (!m_irq_count)
set_irq_line(ASSERT_LINE);
}
}
}
void nes_09034a_device::write_ex(offs_t offset, u8 data)
{
LOG_MMC(("09-034a write_ex, offset: %04x, data: %02x\n", offset, data));
if (offset == 7) // $4027
m_reg = data & 1;
offset += 0x20;
switch (offset)
{
case 0x0027:
m_reg = data & 1;
break;
case 0x0068:
m_irq_enable = BIT(data, 0);
if (!m_irq_enable)
{
m_irq_count = 0;
set_irq_line(CLEAR_LINE);
}
break;
}
}
uint8_t nes_09034a_device::read_m(offs_t offset)
u8 nes_09034a_device::read_ex(offs_t offset)
{
LOG_MMC(("09-034a read_ex, offset: %04x, data: %02x\n", offset));
offset += 0x20;
// SMB2 does not boot with the default open bus reads in this range
if (offset >= 0x42 && offset <= 0x55)
return 0xff;
else
return get_open_bus();
}
u8 nes_09034a_device::read_m(offs_t offset)
{
LOG_MMC(("09-034a read_m, offset: %04x\n", offset));
// in 0x6000-0x7fff is mapped the 2nd PRG chip which starts after 32K (hence the +4)
return m_prg[((m_reg + 4) * 0x2000) + offset];
return m_prg[(((m_reg + 4) * 0x2000) + offset) & (m_prg_size - 1)];
}
/*-------------------------------------------------

View File

@ -260,19 +260,26 @@ class nes_09034a_device : public nes_nrom_device
{
public:
// construction/destruction
nes_09034a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
nes_09034a_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
virtual void write_ex(offs_t offset, uint8_t data) override;
virtual uint8_t read_m(offs_t offset) override;
virtual void write_ex(offs_t offset, u8 data) override;
virtual u8 read_ex(offs_t offset) override;
virtual u8 read_m(offs_t offset) override;
virtual void pcb_reset() override;
protected:
// device-level overrides
virtual void device_start() override;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
private:
uint8_t m_reg;
u16 m_irq_count;
int m_irq_enable;
u8 m_reg;
static const device_timer_id TIMER_IRQ = 0;
emu_timer *irq_timer;
};

View File

@ -83,13 +83,13 @@ void nes_state::machine_start()
space.install_read_handler(0x8000, 0xffff, read8sm_delegate(*m_cartslot, FUNC(nes_cart_slot_device::read_h)));
}
if (m_cartslot->get_pcb_id() == BTL_SMB2JB || m_cartslot->get_pcb_id() == UNL_AC08 || m_cartslot->get_pcb_id() == UNL_SMB2J || m_cartslot->get_pcb_id() == BTL_09034A)
if (m_cartslot->get_pcb_id() == BTL_SMB2JB || m_cartslot->get_pcb_id() == UNL_AC08 || m_cartslot->get_pcb_id() == UNL_SMB2J)
{
logerror("write_ex installed!\n");
space.install_write_handler(0x4020, 0x40ff, write8sm_delegate(*m_cartslot, FUNC(nes_cart_slot_device::write_ex)));
}
if (m_cartslot->get_pcb_id() == KAISER_KS7017 || m_cartslot->get_pcb_id() == UNL_603_5052 || m_cartslot->get_pcb_id() == STD_DISKSYS)
if (m_cartslot->get_pcb_id() == BTL_09034A || m_cartslot->get_pcb_id() == KAISER_KS7017 || m_cartslot->get_pcb_id() == UNL_603_5052 || m_cartslot->get_pcb_id() == STD_DISKSYS)
{
logerror("write_ex & read_ex installed!\n");
space.install_read_handler(0x4020, 0x40ff, read8sm_delegate(*m_cartslot, FUNC(nes_cart_slot_device::read_ex)));