beautified code

This commit is contained in:
spacy51 2008-10-26 20:47:35 +00:00
parent 1b80b3577d
commit 9c8d2d7049
2 changed files with 160 additions and 158 deletions

View File

@ -2356,25 +2356,28 @@ void CPUCheckDMA(int reason, int dmamask)
void CPUUpdateRegister(u32 address, u16 value)
{
switch(address) {
case 0x00:
switch(address)
{
if ((value & 7) >5)
DISPCNT = (value &7);
bool change = ((DISPCNT ^ value) & 0x80) ? true : false;
bool changeBG = ((DISPCNT ^ value) & 0x0F00) ? true : false;
u16 changeBGon = (((~DISPCNT) & value) & 0x0F00);
DISPCNT = (value & 0xFFF7);
case 0x00:
{ // we need to place the following code in { } because we declare & initialize variables in a case statement
if((value & 7) > 5) {
// display modes above 0-5 are prohibited
DISPCNT = (value & 7);
}
bool change = (0 != ((DISPCNT ^ value) & 0x80));
bool changeBG = (0 != ((DISPCNT ^ value) & 0x0F00));
u16 changeBGon = ((~DISPCNT) & value) & 0x0F00; // these layers are being activated
DISPCNT = (value & 0xFFF7); // bit 3 can only be accessed by the BIOS to enable GBC mode
UPDATE_REG(0x00, DISPCNT);
if (changeBGon)
{
layerEnableDelay=4;
if(changeBGon) {
layerEnableDelay = 4;
layerEnable = layerSettings & value & (~changeBGon);
}
else
} else {
layerEnable = layerSettings & value;
// CPUUpdateTicks();
}
windowOn = (layerEnable & 0x6000) ? true : false;
if(change && !((value & 0x80))) {
@ -2390,10 +2393,11 @@ void CPUUpdateRegister(u32 address, u16 value)
}
CPUUpdateRender();
// we only care about changes in BG0-BG3
if(changeBG)
if(changeBG) {
CPUUpdateRenderBuffers(false);
}
break;
}
case 0x04:
DISPSTAT = (value & 0xFF38) | (DISPSTAT & 7);
UPDATE_REG(0x04, DISPSTAT);
@ -2774,7 +2778,7 @@ void CPUUpdateRegister(u32 address, u16 value)
cpuNextEvent = cpuTotalTicks;
break;
case 0x128:
#ifdef LINK_EMULATION
#ifdef LINK_EMULATION
if (linkenable)
{
StartLink(value);
@ -2795,10 +2799,10 @@ void CPUUpdateRegister(u32 address, u16 value)
}
break;
case 0x12a:
#ifdef LINK_EMULATION
#ifdef LINK_EMULATION
if(linkenable && lspeed)
LinkSSend(value);
#endif
#endif
{
UPDATE_REG(0x134, value);
}

View File

@ -17,8 +17,8 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef VBA_GBAinline_H
#define VBA_GBAinline_H
#ifndef GBAINLINE_H
#define GBAINLINE_H
#include "../System.h"
#include "../Port.h"
@ -139,7 +139,7 @@ static inline u32 CPUReadMemory(u32 address)
return flashRead(address);
// default
default:
unreadable:
unreadable:
#ifdef GBA_LOGGING
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
log("Illegal word read: %08x at %08x\n", address, armMode ?
@ -278,7 +278,7 @@ static inline u32 CPUReadHalfWord(u32 address)
return flashRead(address);
// default
default:
unreadable:
unreadable:
#ifdef GBA_LOGGING
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
log("Illegal halfword read: %08x at %08x\n", address, armMode ?
@ -374,7 +374,7 @@ static inline u8 CPUReadByte(u32 address)
}
// default
default:
unreadable:
unreadable:
#ifdef GBA_LOGGING
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
log("Illegal byte read: %08x at %08x\n", address, armMode ?
@ -479,7 +479,7 @@ static inline void CPUWriteMemory(u32 address, u32 value)
}
// default
default:
unwritable:
unwritable:
#ifdef GBA_LOGGING
if(systemVerbose & VERBOSE_ILLEGAL_WRITE) {
log("Illegal word write: %08x to %08x from %08x\n",
@ -581,7 +581,7 @@ static inline void CPUWriteHalfWord(u32 address, u16 value)
}
goto unwritable;
default:
unwritable:
unwritable:
#ifdef GBA_LOGGING
if(systemVerbose & VERBOSE_ILLEGAL_WRITE) {
log("Illegal halfword write: %04x to %08x from %08x\n",
@ -616,13 +616,6 @@ static inline void CPUWriteByte(u32 address, u8 b)
case 4:
if(address < 0x4000400) {
switch(address & 0x3FF) {
case 0x301:
if(b == 0x80)
stopState = true;
holdState = 1;
holdType = -1;
cpuNextEvent = cpuTotalTicks;
break;
case 0x60:
case 0x61:
case 0x62:
@ -665,15 +658,20 @@ static inline void CPUWriteByte(u32 address, u8 b)
case 0x9f:
soundEvent(address&0xFF, b);
break;
default:
if(address & 1)
CPUUpdateRegister(address & 0x3fe,
((READ16LE(((u16 *)&ioMem[address & 0x3fe])))
& 0x00FF) |
b<<8);
else
CPUUpdateRegister(address & 0x3fe,
((READ16LE(((u16 *)&ioMem[address & 0x3fe])) & 0xFF00) | b));
case 0x301: // HALTCNT, undocumented
if(b == 0x80)
stopState = true;
holdState = 1;
holdType = -1;
cpuNextEvent = cpuTotalTicks;
break;
default: // every other register
u32 lowerBits = address & 0x3fe;
if(address & 1) {
CPUUpdateRegister(lowerBits, (READ16LE(&ioMem[lowerBits]) & 0x00FF) | (b << 8));
} else {
CPUUpdateRegister(lowerBits, (READ16LE(&ioMem[lowerBits]) & 0xFF00) | b);
}
}
break;
} else goto unwritable;
@ -722,7 +720,7 @@ static inline void CPUWriteByte(u32 address, u8 b)
}
// default
default:
unwritable:
unwritable:
#ifdef GBA_LOGGING
if(systemVerbose & VERBOSE_ILLEGAL_WRITE) {
log("Illegal byte write: %02x to %08x from %08x\n",
@ -735,4 +733,4 @@ static inline void CPUWriteByte(u32 address, u8 b)
}
}
#endif //VBA_GBAinline_H
#endif //GBAINLINE_H