summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2021-04-04 13:28:06 -0700
committer Aaron Giles <aaron@aarongiles.com>2021-04-04 13:28:06 -0700
commit47e9aa7d6bbef2f96e63cded271fa54f8c9e6836 (patch)
tree44a01b9d894c0b8cbd8ba464a3b10fb679bd63d9
parent17c64fa3727e728bf0c3ebb3cc9722e70601a1e1 (diff)
ymf278b: Fix ID register implementation; fixes several metro games that were hanging.
-rw-r--r--src/devices/sound/ymf278b.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/devices/sound/ymf278b.cpp b/src/devices/sound/ymf278b.cpp
index 9c27849ee1e..ae84815ce67 100644
--- a/src/devices/sound/ymf278b.cpp
+++ b/src/devices/sound/ymf278b.cpp
@@ -664,23 +664,26 @@ u8 ymf278b_device::read(offs_t offset)
{
// status register
case 0:
- ret = m_fm.status();
- // if new2 flag is not set, we're in OPL2 or OPL3 mode
- if (!m_fm.regs().new2flag())
+ // first status read after initialization returns a chip ID, which
+ // varies based on the "new" flags, indicating the mode
+ if (m_next_status_id)
{
- // these bits are not reported in OPL2/3 mode
- ret &= ~(STATUS_BUSY | STATUS_LD);
-
- // if in OPL2 mode, bits 1 and 2 are returned on
- if (!m_fm.regs().newflag())
- ret |= 0x06;
+ if (m_fm.regs().new2flag())
+ ret = 0x02;
+ else if (m_fm.regs().newflag())
+ ret = 0x00;
+ else
+ ret = 0x06;
+ m_next_status_id = false;
}
- else if (m_next_status_id)
+ else
{
- // if new2 flag was just changed to on, then the next read will be 0x02
- ret |= 0x02;
- m_next_status_id = false;
+ ret = m_fm.status();
+
+ // if new2 flag is not set, we're in OPL2 or OPL3 mode
+ if (!m_fm.regs().new2flag())
+ ret &= ~(STATUS_BUSY | STATUS_LD);
}
break;
@@ -743,7 +746,7 @@ void ymf278b_device::device_reset()
m_port_AB = m_port_C = 0;
m_lastport = 0;
- m_next_status_id = false;
+ m_next_status_id = true;
m_memadr = 0;
// init/silence channels