Implement memory mirrors for SRAM/FLASH.

Correctly handle 16/32bit reads from SRAM.
Removed unaligned handler for CPUReadHalfWordSigned.
This commit is contained in:
normmatt234 2013-09-18 22:08:42 +00:00
parent 620548d19e
commit 943f67937c
1 changed files with 18 additions and 11 deletions

View File

@ -119,9 +119,13 @@ static inline u32 CPUReadMemory(u32 address)
return eepromRead(address);
goto unreadable;
case 14:
case 15:
if(cpuFlashEnabled | cpuSramEnabled)
{
// no need to swap this
return flashRead(address);
value = flashRead(address) * 0x01010101;
break;
}
// default
default:
unreadable:
@ -266,9 +270,13 @@ static inline u32 CPUReadHalfWord(u32 address)
return eepromRead(address);
goto unreadable;
case 14:
case 15:
if(cpuFlashEnabled | cpuSramEnabled)
{
// no need to swap this
return flashRead(address);
value = flashRead(address) * 0x0101;
break;
}
// default
default:
unreadable:
@ -305,22 +313,17 @@ unreadable:
static inline s16 CPUReadHalfWordSigned(u32 address)
{
u32 oldAddress = address;
if(address & 1) {
address &= ~0x01;
}
s16 value = (s16)CPUReadHalfWord(address);
if((oldAddress & 1))
s32 value = (s32)CPUReadHalfWord(address);
if((address & 1))
{
value = (s8)value;
#ifdef GBA_LOGGING
if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) {
log("Unaligned signed halfword read from: %08x at %08x (%08x)\n", oldAddress, armMode ?
log("Unaligned signed halfword read from: %08x at %08x (%08x)\n", address, armMode ?
armNextPC - 4 : armNextPC - 2, value);
}
#endif
}
return value;
return (s16)value;
}
static inline u8 CPUReadByte(u32 address)
@ -369,6 +372,7 @@ static inline u8 CPUReadByte(u32 address)
return eepromRead(address);
goto unreadable;
case 14:
case 15:
if(cpuSramEnabled | cpuFlashEnabled)
return flashRead(address);
if(cpuEEPROMSensorEnabled) {
@ -486,6 +490,7 @@ static inline void CPUWriteMemory(u32 address, u32 value)
}
goto unwritable;
case 0x0E:
case 0x0F:
if((!eepromInUse) | cpuSramEnabled | cpuFlashEnabled) {
(*cpuSaveGameFunc)(address, (u8)value);
break;
@ -590,6 +595,7 @@ static inline void CPUWriteHalfWord(u32 address, u16 value)
}
goto unwritable;
case 14:
case 15:
if((!eepromInUse) | cpuSramEnabled | cpuFlashEnabled) {
(*cpuSaveGameFunc)(address, (u8)value);
break;
@ -726,6 +732,7 @@ static inline void CPUWriteByte(u32 address, u8 b)
}
goto unwritable;
case 14:
case 15:
if ((saveType != 5) && ((!eepromInUse) | cpuSramEnabled | cpuFlashEnabled)) {
//if(!cpuEEPROMEnabled && (cpuSramEnabled | cpuFlashEnabled)) {