Pass OAM tests now.

This commit is contained in:
Brandon Wright 2018-07-02 17:35:15 -05:00
parent 645f47187a
commit 893069da5f
2 changed files with 18 additions and 28 deletions

View File

@ -485,7 +485,7 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
case 0x2102: // OAMADDL case 0x2102: // OAMADDL
PPU.OAMAddr = ((Memory.FillRAM[0x2103] & 1) << 8) | Byte; PPU.OAMAddr = ((Memory.FillRAM[0x2103] & 1) << 8) | Byte;
PPU.OAMFlip = 2; PPU.OAMFlip = 0;
PPU.OAMReadFlip = 0; PPU.OAMReadFlip = 0;
PPU.SavedOAMAddr = PPU.OAMAddr; PPU.SavedOAMAddr = PPU.OAMAddr;
if (PPU.OAMPriorityRotation && PPU.FirstSprite != (PPU.OAMAddr >> 1)) if (PPU.OAMPriorityRotation && PPU.FirstSprite != (PPU.OAMAddr >> 1))

44
ppu.h
View File

@ -419,6 +419,12 @@ static inline void FLUSH_REDRAW (void)
static inline void REGISTER_2104 (uint8 Byte) static inline void REGISTER_2104 (uint8 Byte)
{ {
if (!(PPU.OAMFlip & 1))
{
PPU.OAMWriteRegister &= 0xff00;
PPU.OAMWriteRegister |= Byte;
}
if (PPU.OAMAddr & 0x100) if (PPU.OAMAddr & 0x100)
{ {
int addr = ((PPU.OAMAddr & 0x10f) << 1) + (PPU.OAMFlip & 1); int addr = ((PPU.OAMAddr & 0x10f) << 1) + (PPU.OAMFlip & 1);
@ -440,33 +446,8 @@ static inline void REGISTER_2104 (uint8 Byte)
pObj->Size = Byte & 128; pObj->Size = Byte & 128;
} }
PPU.OAMFlip ^= 1;
if (!(PPU.OAMFlip & 1))
{
++PPU.OAMAddr;
PPU.OAMAddr &= 0x1ff;
if (PPU.OAMPriorityRotation && PPU.FirstSprite != (PPU.OAMAddr >> 1))
{
PPU.FirstSprite = (PPU.OAMAddr & 0xfe) >> 1;
IPPU.OBJChanged = TRUE;
}
}
else
{
if (PPU.OAMPriorityRotation && (PPU.OAMAddr & 1))
IPPU.OBJChanged = TRUE;
}
} }
else else if (PPU.OAMFlip & 1)
if (!(PPU.OAMFlip & 1))
{
PPU.OAMWriteRegister &= 0xff00;
PPU.OAMWriteRegister |= Byte;
PPU.OAMFlip |= 1;
if (PPU.OAMPriorityRotation && (PPU.OAMAddr & 1))
IPPU.OBJChanged = TRUE;
}
else
{ {
PPU.OAMWriteRegister &= 0x00ff; PPU.OAMWriteRegister &= 0x00ff;
uint8 lowbyte = (uint8) (PPU.OAMWriteRegister); uint8 lowbyte = (uint8) (PPU.OAMWriteRegister);
@ -499,15 +480,24 @@ static inline void REGISTER_2104 (uint8 Byte)
PPU.OBJ[addr].VPos = highbyte; PPU.OBJ[addr].VPos = highbyte;
} }
} }
}
PPU.OAMFlip &= ~1; PPU.OAMFlip ^= 1;
if (!(PPU.OAMFlip & 1))
{
++PPU.OAMAddr; ++PPU.OAMAddr;
PPU.OAMAddr &= 0x1ff;
if (PPU.OAMPriorityRotation && PPU.FirstSprite != (PPU.OAMAddr >> 1)) if (PPU.OAMPriorityRotation && PPU.FirstSprite != (PPU.OAMAddr >> 1))
{ {
PPU.FirstSprite = (PPU.OAMAddr & 0xfe) >> 1; PPU.FirstSprite = (PPU.OAMAddr & 0xfe) >> 1;
IPPU.OBJChanged = TRUE; IPPU.OBJChanged = TRUE;
} }
} }
else
{
if (PPU.OAMPriorityRotation && (PPU.OAMAddr & 1))
IPPU.OBJChanged = TRUE;
}
} }
// This code is correct, however due to Snes9x's inaccurate timings, some games might be broken by this chage. :( // This code is correct, however due to Snes9x's inaccurate timings, some games might be broken by this chage. :(