summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author 0kmg <9137159+0kmg@users.noreply.github.com>2021-08-19 07:07:40 -0800
committer GitHub <noreply@github.com>2021-08-19 11:07:40 -0400
commitb83a06f032c9785158ba78807eca58a1d8847680 (patch)
treeec28d9a4b26fbf39f163ca46b300088e5e5974f3
parent4ea2e83412c98935c9fc0030f82aadd014bc8122 (diff)
bus/nes: Fixed IRQ timing for Sunsoft 3 boards. (#8458)
-rw-r--r--src/devices/bus/nes/sunsoft.cpp33
-rw-r--r--src/devices/bus/nes/sunsoft.h2
2 files changed, 11 insertions, 24 deletions
diff --git a/src/devices/bus/nes/sunsoft.cpp b/src/devices/bus/nes/sunsoft.cpp
index 926b1933c91..c5baffe74ea 100644
--- a/src/devices/bus/nes/sunsoft.cpp
+++ b/src/devices/bus/nes/sunsoft.cpp
@@ -16,7 +16,7 @@
* Sunsoft-5B [mapper 69]
TODO:
- - check 1-line glitches due to IRQ in Sunsoft-3
+ - 1-line glitches in Fantasy Zone II (Sunsoft-3) seem to be PPU timing related. The cycle-based IRQ timer below "should" be ok.
***********************************************************************************************************/
@@ -136,6 +136,7 @@ void nes_sunsoft_3_device::pcb_reset()
prg16_89ab(0);
prg16_cdef(m_prg_chunks - 1);
chr8(0, m_chr_source);
+
m_irq_toggle = 0;
m_irq_count = 0;
m_irq_enable = 0;
@@ -256,28 +257,20 @@ void nes_sunsoft_2_device::write_h(offs_t offset, uint8_t data)
Sunsoft-3 board emulation
- The two games using this board have incompatible mirroring
- wiring, making necessary two distinct mappers & pcb_id
+ Games: Fantasy Zone II, Mito Koumon II - Sekai Manyuki
iNES: mapper 67
-------------------------------------------------*/
-
void nes_sunsoft_3_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
if (id == TIMER_IRQ)
{
- if (m_irq_enable)
+ if (m_irq_enable && --m_irq_count == 0xffff)
{
- if (!m_irq_count)
- {
- set_irq_line(ASSERT_LINE);
- m_irq_count = 0xffff;
- m_irq_enable = 0;
- }
- else
- m_irq_count--;
+ set_irq_line(ASSERT_LINE);
+ m_irq_enable = 0;
}
}
}
@@ -289,18 +282,11 @@ void nes_sunsoft_3_device::write_h(offs_t offset, uint8_t data)
switch (offset & 0x7800)
{
case 0x0800:
- chr2_0(data, CHRROM);
- break;
case 0x1800:
- chr2_2(data, CHRROM);
- break;
case 0x2800:
- chr2_4(data, CHRROM);
- break;
case 0x3800:
- chr2_6(data, CHRROM);
+ chr2_x((offset >> 11) & 0x06, data & 0x3f, CHRROM);
break;
- case 0x4000:
case 0x4800:
m_irq_toggle ^= 1;
if (m_irq_toggle)
@@ -311,7 +297,6 @@ void nes_sunsoft_3_device::write_h(offs_t offset, uint8_t data)
case 0x5800:
m_irq_enable = BIT(data, 4);
m_irq_toggle = 0;
- set_irq_line(CLEAR_LINE);
break;
case 0x6800:
switch (data & 3)
@@ -323,10 +308,10 @@ void nes_sunsoft_3_device::write_h(offs_t offset, uint8_t data)
}
break;
case 0x7800:
- prg16_89ab(data);
+ prg16_89ab(data & 0x0f);
break;
default:
- LOG_MMC(("Sunsoft 3 write_h uncaught write, offset: %04x, data: %02x\n", offset, data));
+ set_irq_line(CLEAR_LINE);
break;
}
}
diff --git a/src/devices/bus/nes/sunsoft.h b/src/devices/bus/nes/sunsoft.h
index c02b94647cf..6eb3f6b7af4 100644
--- a/src/devices/bus/nes/sunsoft.h
+++ b/src/devices/bus/nes/sunsoft.h
@@ -61,6 +61,7 @@ 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:
uint16_t m_irq_count;
int m_irq_enable, m_irq_toggle;
@@ -96,6 +97,7 @@ protected:
int m_reg, m_latch1, m_latch2, m_wram_enable;
};
+
// ======================> nes_sunsoft_fme7_device
class nes_sunsoft_fme7_device : public nes_nrom_device