summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatarGravatar AJR <ajrhacker@users.noreply.github.com>2019-09-13 13:44:21 -0400
committerGravatarGravatar AJR <ajrhacker@users.noreply.github.com>2019-09-13 15:23:45 -0400
commit547828756f1861e367d2c7380d2438caab337d51 (patch) (github)
tree54168449e29bd601e54f877810edc2ea81fa3396
parenta06f9b74f634e08c5f2b70d6cbed4b8176b14a8f (diff)
downloadmame-547828756f1861e367d2c7380d2438caab337d51.tar.bz2
mame-547828756f1861e367d2c7380d2438caab337d51.zip
riscii: Improve offset calculation for TBRD (nw)
-rw-r--r--src/devices/cpu/rii/riscii.cpp12
-rw-r--r--src/devices/cpu/rii/riscii.h1
2 files changed, 10 insertions, 3 deletions
diff --git a/src/devices/cpu/rii/riscii.cpp b/src/devices/cpu/rii/riscii.cpp
index 89c3eb533ea..c7b158bf3e0 100644
--- a/src/devices/cpu/rii/riscii.cpp
+++ b/src/devices/cpu/rii/riscii.cpp
@@ -384,6 +384,11 @@ u16 riscii_series_device::get_banked_address(u8 reg)
return reg;
}
+u32 riscii_series_device::tabptr_offset(int offset) const
+{
+ return (m_tabptr & 0x800000) | ((m_tabptr + offset) & ((1 << (m_prgbits + 1)) - 1));
+}
+
//**************************************************************************
// EXECUTION CORE
@@ -1053,6 +1058,7 @@ void riscii_series_device::execute_cycle1(u16 opcode)
void riscii_series_device::execute_tbrd(u32 ptr)
{
+ // TODO: "Bit 23 is used to select the internal/external memory"
u16 addr = get_banked_address(m_curreg);
u16 data = m_program->read_word(ptr >> 1);
if (BIT(ptr, 0))
@@ -1092,15 +1098,15 @@ void riscii_series_device::execute_run()
break;
case EXEC_TBRD1:
- execute_tbrd(m_tabptr++);
+ execute_tbrd(std::exchange(m_tabptr, tabptr_offset(1)));
break;
case EXEC_TBRD2:
- execute_tbrd(m_tabptr--);
+ execute_tbrd(std::exchange(m_tabptr, tabptr_offset(-1)));
break;
case EXEC_TBRDA:
- execute_tbrd(m_tabptr + m_acc);
+ execute_tbrd(tabptr_offset(m_acc));
break;
case EXEC_L0JMP: case EXEC_L1JMP: case EXEC_L2JMP: case EXEC_L3JMP:
diff --git a/src/devices/cpu/rii/riscii.h b/src/devices/cpu/rii/riscii.h
index f00b378fd5b..df6a1199da3 100644
--- a/src/devices/cpu/rii/riscii.h
+++ b/src/devices/cpu/rii/riscii.h
@@ -95,6 +95,7 @@ private:
// memory helpers
u16 get_banked_address(u8 reg);
+ u32 tabptr_offset(int offset) const;
// execution
void execute_move(u8 dstreg, u8 srcreg);