8000 ymfm_opn.cpp: correct write latch behaviour by happppp · Pull Request #67 · aaronsgiles/ymfm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ymfm_opn.cpp: correct write latch behaviour #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/ymfm_opn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,26 +143,23 @@ bool opn_registers_base<IsOpnA>::write(uint16_t index, uint8_t data, uint32_t &c
assert(index < REGISTERS);

// writes in the 0xa0-af/0x1a0-af region are handled as latched pairs
// borrow unused registers 0xb8-bf/0x1b8-bf as temporary holding locations
// borrow unused registers 0xb8-bf as temporary holding locations
if ((index & 0xf0) == 0xa0)
{
if (bitfield(index, 0, 2) == 3)
return false;

uint32_t latchindex = 0xb8 | bitfield(index, 3);
if (IsOpnA)
latchindex |= index & 0x100;

// writes to the upper half just latch (only low 6 bits matter)
if (bitfield(index, 2))
m_regdata[latchindex] = data | 0x80;
m_regdata[latchindex] = data & 0x3f;

// writes to the lower half only commit if the latch is there
else if (bitfield(m_regdata[latchindex], 7))
// writes to the lower half also apply said latch
else
{
m_regdata[index] = data;
m_regdata[index | 4] = m_regdata[latchindex] & 0x3f;
m_regdata[latchindex] = 0;
m_regdata[index | 4] = m_regdata[latchindex];
}
return false;
}
Expand Down
0