summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/sh
diff options
context:
space:
mode:
author angelosa <lordkale4@gmail.com>2025-11-16 19:54:31 +0100
committer angelosa <lordkale4@gmail.com>2025-11-16 19:54:31 +0100
commit661381746bf01462df2c40f3567918293a70a379 (patch)
treec6ba6b5606f821421728b2085c345ac7d698bce9 /src/devices/cpu/sh
parent3c38125ab387f16ba3dd083e6be8b398254f0b96 (diff)
cpu/sh/sh7604.cpp: fix BCR1/BCR2 and VCRDIV accessing
Diffstat (limited to 'src/devices/cpu/sh')
-rw-r--r--src/devices/cpu/sh/sh7604.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/devices/cpu/sh/sh7604.cpp b/src/devices/cpu/sh/sh7604.cpp
index 54205d5c0cc..7841c578c07 100644
--- a/src/devices/cpu/sh/sh7604.cpp
+++ b/src/devices/cpu/sh/sh7604.cpp
@@ -1083,16 +1083,17 @@ void sh7604_device::vcrwdt_w(offs_t offset, uint16_t data, uint16_t mem_mask)
sh2_recalc_irq();
}
+// VCRDIV is a word register where bits 6-0 have a meaning, reads back written word value
uint32_t sh7604_device::vcrdiv_r()
{
- return m_vcrdiv & 0x7f;
+ return m_vcrdiv & 0xffff;
}
void sh7604_device::vcrdiv_w(offs_t offset, uint32_t data, uint32_t mem_mask)
{
COMBINE_DATA(&m_vcrdiv);
// TODO: unemulated, level is seemingly not documented/settable?
- m_irq_vector.divu = data & 0x7f;
+ m_irq_vector.divu = m_vcrdiv & 0x7f;
sh2_recalc_irq();
}
@@ -1356,6 +1357,8 @@ void sh7604_device::ccr_w(uint8_t data)
m_ccr = data;
}
+// BCR1/BCR2 are really 16-bit wide, when accessed as dword the upper part is used as unlock
+// method (0xa55axxxx) and reads back 0.
uint32_t sh7604_device::bcr1_r()
{
return (m_bcr1 & ~0xe008) | (m_is_slave ? 0x8000 : 0);
@@ -1363,7 +1366,16 @@ uint32_t sh7604_device::bcr1_r()
void sh7604_device::bcr1_w(offs_t offset, uint32_t data, uint32_t mem_mask)
{
- COMBINE_DATA(&m_bcr1);
+ if (ACCESSING_BITS_0_31)
+ {
+ if ((data & 0xffff0000) == 0xa55a0000)
+ {
+ COMBINE_DATA(&m_bcr1);
+ m_bcr1 &= 0xffff;
+ }
+ }
+ else if (ACCESSING_BITS_0_15)
+ COMBINE_DATA(&m_bcr1);
}
uint32_t sh7604_device::bcr2_r()
@@ -1373,7 +1385,16 @@ uint32_t sh7604_device::bcr2_r()
void sh7604_device::bcr2_w(offs_t offset, uint32_t data, uint32_t mem_mask)
{
- COMBINE_DATA(&m_bcr2);
+ if (ACCESSING_BITS_0_31)
+ {
+ if ((data & 0xffff0000) == 0xa55a0000)
+ {
+ COMBINE_DATA(&m_bcr2);
+ m_bcr2 &= 0xffff;
+ }
+ }
+ else if (ACCESSING_BITS_0_15)
+ COMBINE_DATA(&m_bcr2);
}
uint32_t sh7604_device::wcr_r()