summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/se3208/se3208.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/cpu/se3208/se3208.cpp')
-rw-r--r--src/devices/cpu/se3208/se3208.cpp56
1 files changed, 40 insertions, 16 deletions
diff --git a/src/devices/cpu/se3208/se3208.cpp b/src/devices/cpu/se3208/se3208.cpp
index 98a87335d33..b37a8e09f5f 100644
--- a/src/devices/cpu/se3208/se3208.cpp
+++ b/src/devices/cpu/se3208/se3208.cpp
@@ -38,23 +38,38 @@
//Precompute the instruction decoding in a big table
#define INST(a) void se3208_device::a(UINT16 Opcode)
+// officeye and donghaer perform unaligned DWORD accesses, allowing them to happen causes the games to malfunction.
+// are such accesses simply illegal, be handled in a different way, or simply not be happening in the first place?
+#define ALLOW_UNALIGNED_DWORD_ACCESS 0
const device_type SE3208 = &device_creator<se3208_device>;
se3208_device::se3208_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: cpu_device(mconfig, SE3208, "SE3208", tag, owner, clock, "se3208", __FILE__)
- , m_program_config("program", ENDIANNESS_LITTLE, 32, 32, 0)
+ , m_program_config("program", ENDIANNESS_LITTLE, 32, 32, 0), m_PC(0), m_SR(0), m_SP(0), m_ER(0), m_PPC(0), m_program(nullptr), m_direct(nullptr), m_IRQ(0), m_NMI(0), m_icount(0)
{
}
UINT32 se3208_device::read_dword_unaligned(address_space &space, UINT32 address)
{
- if (address & 3)
- return space.read_byte(address) | space.read_byte(address+1)<<8 | space.read_byte(address+2)<<16 | space.read_byte(address+3)<<24;
- else
+ switch (address & 3)
+ {
+ case 0:
return space.read_dword(address);
+ case 1:
+ case 2:
+ case 3:
+ printf("%08x: dword READ unaligned %08x\n", m_PC, address);
+#if ALLOW_UNALIGNED_DWORD_ACCESS
+ return space.read_byte(address) | space.read_byte(address + 1) << 8 | space.read_byte(address + 2) << 16 | space.read_byte(address + 3) << 24;
+#else
+ return 0;
+#endif
+ }
+
+ return 0;
}
UINT16 se3208_device::read_word_unaligned(address_space &space, UINT32 address)
@@ -67,17 +82,26 @@ UINT16 se3208_device::read_word_unaligned(address_space &space, UINT32 address)
void se3208_device::write_dword_unaligned(address_space &space, UINT32 address, UINT32 data)
{
- if (address & 3)
- {
- space.write_byte(address, data & 0xff);
- space.write_byte(address+1, (data>>8)&0xff);
- space.write_byte(address+2, (data>>16)&0xff);
- space.write_byte(address+3, (data>>24)&0xff);
- }
- else
+ switch (address & 3)
{
+ case 0:
space.write_dword(address, data);
+ break;
+
+ case 1:
+ case 2:
+ case 3:
+#if ALLOW_UNALIGNED_DWORD_ACCESS
+ space.write_byte(address, data & 0xff);
+ space.write_byte(address + 1, (data >> 8) & 0xff);
+ space.write_byte(address + 2, (data >> 16) & 0xff);
+ space.write_byte(address + 3, (data >> 24) & 0xff);
+#endif
+ printf("%08x: dword WRITE unaligned %08x\n", m_PC, address);
+
+ break;
}
+
}
void se3208_device::write_word_unaligned(address_space &space, UINT32 address, UINT16 data)
@@ -550,7 +574,7 @@ INST(LEATOSP)
else
Offset=SEX(4,Offset);
- m_SP=Index+Offset;
+ m_SP=(Index+Offset) & (~3);
CLRFLAG(FLAG_E);
}
@@ -581,7 +605,7 @@ INST(LEASPTOSP)
else
Offset=SEX(10,Offset);
- m_SP=m_SP+Offset;
+ m_SP=(m_SP+Offset) & (~3);
CLRFLAG(FLAG_E);
}
@@ -1691,9 +1715,9 @@ void se3208_device::BuildTable(void)
void se3208_device::device_reset()
{
- for ( int i = 0; i < 8; i++ )
+ for (auto & elem : m_R)
{
- m_R[i] = 0;
+ elem = 0;
}
m_SP = 0;
m_ER = 0;