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)
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 = ((DISPCNT ^ value) & 0x80) ? true : false;
bool changeBG = ((DISPCNT ^ value) & 0x0F00) ? true : false;
u16 changeBGon = (((~DISPCNT) & value) & 0x0F00);
DISPCNT = (value & 0xFFF7);
}
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)
{
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);

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"
@ -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;
@ -735,4 +733,4 @@ static inline void CPUWriteByte(u32 address, u8 b)
}
}
#endif //VBA_GBAinline_H
#endif //GBAINLINE_H