beautified code

git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@782 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
spacy51 2008-10-26 20:47:35 +00:00
parent 93f5527ded
commit 009c70cd7d
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) void CPUUpdateRegister(u32 address, u16 value)
{ {
switch(address) { switch(address)
case 0x00:
{ {
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); DISPCNT = (value & 7);
bool change = ((DISPCNT ^ value) & 0x80) ? true : false; }
bool changeBG = ((DISPCNT ^ value) & 0x0F00) ? true : false; bool change = (0 != ((DISPCNT ^ value) & 0x80));
u16 changeBGon = (((~DISPCNT) & value) & 0x0F00); bool changeBG = (0 != ((DISPCNT ^ value) & 0x0F00));
DISPCNT = (value & 0xFFF7); 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); UPDATE_REG(0x00, DISPCNT);
if (changeBGon) if(changeBGon) {
{
layerEnableDelay = 4; layerEnableDelay = 4;
layerEnable = layerSettings & value & (~changeBGon); layerEnable = layerSettings & value & (~changeBGon);
} } else {
else
layerEnable = layerSettings & value; layerEnable = layerSettings & value;
// CPUUpdateTicks(); // CPUUpdateTicks();
}
windowOn = (layerEnable & 0x6000) ? true : false; windowOn = (layerEnable & 0x6000) ? true : false;
if(change && !((value & 0x80))) { if(change && !((value & 0x80))) {
@ -2390,10 +2393,11 @@ void CPUUpdateRegister(u32 address, u16 value)
} }
CPUUpdateRender(); CPUUpdateRender();
// we only care about changes in BG0-BG3 // we only care about changes in BG0-BG3
if(changeBG) if(changeBG) {
CPUUpdateRenderBuffers(false); CPUUpdateRenderBuffers(false);
} }
break; break;
}
case 0x04: case 0x04:
DISPSTAT = (value & 0xFF38) | (DISPSTAT & 7); DISPSTAT = (value & 0xFF38) | (DISPSTAT & 7);
UPDATE_REG(0x04, DISPSTAT); UPDATE_REG(0x04, DISPSTAT);

View File

@ -17,8 +17,8 @@
// along with this program; if not, write to the Free Software Foundation, // along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef VBA_GBAinline_H #ifndef GBAINLINE_H
#define VBA_GBAinline_H #define GBAINLINE_H
#include "../System.h" #include "../System.h"
#include "../Port.h" #include "../Port.h"
@ -616,13 +616,6 @@ static inline void CPUWriteByte(u32 address, u8 b)
case 4: case 4:
if(address < 0x4000400) { if(address < 0x4000400) {
switch(address & 0x3FF) { switch(address & 0x3FF) {
case 0x301:
if(b == 0x80)
stopState = true;
holdState = 1;
holdType = -1;
cpuNextEvent = cpuTotalTicks;
break;
case 0x60: case 0x60:
case 0x61: case 0x61:
case 0x62: case 0x62:
@ -665,15 +658,20 @@ static inline void CPUWriteByte(u32 address, u8 b)
case 0x9f: case 0x9f:
soundEvent(address&0xFF, b); soundEvent(address&0xFF, b);
break; break;
default: case 0x301: // HALTCNT, undocumented
if(address & 1) if(b == 0x80)
CPUUpdateRegister(address & 0x3fe, stopState = true;
((READ16LE(((u16 *)&ioMem[address & 0x3fe]))) holdState = 1;
& 0x00FF) | holdType = -1;
b<<8); cpuNextEvent = cpuTotalTicks;
else break;
CPUUpdateRegister(address & 0x3fe, default: // every other register
((READ16LE(((u16 *)&ioMem[address & 0x3fe])) & 0xFF00) | b)); u32 lowerBits = address & 0x3fe;
if(address & 1) {
CPUUpdateRegister(lowerBits, (READ16LE(&ioMem[lowerBits]) & 0x00FF) | (b << 8));
} else {
CPUUpdateRegister(lowerBits, (READ16LE(&ioMem[lowerBits]) & 0xFF00) | b);
}
} }
break; break;
} else goto unwritable; } else goto unwritable;
@ -735,4 +733,4 @@ static inline void CPUWriteByte(u32 address, u8 b)
} }
} }
#endif //VBA_GBAinline_H #endif //GBAINLINE_H