Fixed unaligned 16/32 bit reads.
git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@1172 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
parent
15078814b7
commit
81f6d88f65
|
@ -46,23 +46,24 @@ extern int cpuTotalTicks;
|
||||||
|
|
||||||
static inline u32 CPUReadMemory(u32 address)
|
static inline u32 CPUReadMemory(u32 address)
|
||||||
{
|
{
|
||||||
#ifdef GBA_LOGGING
|
int shift;
|
||||||
|
u32 value;
|
||||||
|
u32 oldAddress = address;
|
||||||
|
|
||||||
|
#ifdef C_CORE
|
||||||
if(address & 3) {
|
if(address & 3) {
|
||||||
if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) {
|
shift = (address & 3) << 3;
|
||||||
log("Unaligned word read: %08x at %08x\n", address, armMode ?
|
address &= ~0x03;
|
||||||
armNextPC - 4 : armNextPC - 2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
u32 value;
|
|
||||||
switch(address >> 24) {
|
switch(address >> 24) {
|
||||||
case 0:
|
case 0:
|
||||||
if(reg[15].I >> 24) {
|
if(reg[15].I >> 24) {
|
||||||
if(address < 0x4000) {
|
if(address < 0x4000) {
|
||||||
#ifdef GBA_LOGGING
|
#ifdef GBA_LOGGING
|
||||||
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
|
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
|
||||||
log("Illegal word read: %08x at %08x\n", address, armMode ?
|
log("Illegal word read from bios: %08x at %08x\n", address, armMode ?
|
||||||
armNextPC - 4 : armNextPC - 2);
|
armNextPC - 4 : armNextPC - 2);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -145,6 +146,7 @@ unreadable:
|
||||||
CPUReadHalfWordQuick(reg[15].I) << 16;
|
CPUReadHalfWordQuick(reg[15].I) << 16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(address & 3) {
|
if(address & 3) {
|
||||||
|
@ -168,6 +170,15 @@ unreadable:
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef GBA_LOGGING
|
||||||
|
if(oldAddress & 3) {
|
||||||
|
if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) {
|
||||||
|
log("Unaligned word read from: %08x at %08x (%08x)\n", oldAddress, armMode ?
|
||||||
|
armNextPC - 4 : armNextPC - 2, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,16 +186,14 @@ extern u32 myROM[];
|
||||||
|
|
||||||
static inline u32 CPUReadHalfWord(u32 address)
|
static inline u32 CPUReadHalfWord(u32 address)
|
||||||
{
|
{
|
||||||
#ifdef GBA_LOGGING
|
|
||||||
if(address & 1) {
|
|
||||||
if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) {
|
|
||||||
log("Unaligned halfword read: %08x at %08x\n", address, armMode ?
|
|
||||||
armNextPC - 4 : armNextPC - 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
u32 value;
|
u32 value;
|
||||||
|
u32 oldAddress = address;
|
||||||
|
|
||||||
|
//#ifdef C_CORE
|
||||||
|
if(address & 1) {
|
||||||
|
address &= ~0x01;
|
||||||
|
}
|
||||||
|
//#endif
|
||||||
|
|
||||||
switch(address >> 24) {
|
switch(address >> 24) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -192,7 +201,7 @@ static inline u32 CPUReadHalfWord(u32 address)
|
||||||
if(address < 0x4000) {
|
if(address < 0x4000) {
|
||||||
#ifdef GBA_LOGGING
|
#ifdef GBA_LOGGING
|
||||||
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
|
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
|
||||||
log("Illegal halfword read: %08x at %08x\n", address, armMode ?
|
log("Illegal halfword read from bios: %08x at %08x\n", address, armMode ?
|
||||||
armNextPC - 4 : armNextPC - 2);
|
armNextPC - 4 : armNextPC - 2);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -289,6 +298,15 @@ unreadable:
|
||||||
value = (value >> 8) | (value << 24);
|
value = (value >> 8) | (value << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef GBA_LOGGING
|
||||||
|
if(oldAddress & 1) {
|
||||||
|
if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) {
|
||||||
|
log("Unaligned halfword read from: %08x at %08x (%08x)\n", oldAddress, armMode ?
|
||||||
|
armNextPC - 4 : armNextPC - 2, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,7 +326,7 @@ static inline u8 CPUReadByte(u32 address)
|
||||||
if(address < 0x4000) {
|
if(address < 0x4000) {
|
||||||
#ifdef GBA_LOGGING
|
#ifdef GBA_LOGGING
|
||||||
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
|
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
|
||||||
log("Illegal byte read: %08x at %08x\n", address, armMode ?
|
log("Illegal byte read from bios: %08x at %08x\n", address, armMode ?
|
||||||
armNextPC - 4 : armNextPC - 2);
|
armNextPC - 4 : armNextPC - 2);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue