Merge pull request #412 from Dwedit/snes9x-master-fix-submission

Move `VRAMReadBuffer` from `IPPU` to `PPU`, then add to savestate
This commit is contained in:
OV2 2018-08-25 21:22:41 +02:00 committed by GitHub
commit 1d25cbfeca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 13 deletions

22
ppu.cpp
View File

@ -721,10 +721,10 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
uint32 addr = PPU.VMA.Address; uint32 addr = PPU.VMA.Address;
uint32 rem = addr & PPU.VMA.Mask1; uint32 rem = addr & PPU.VMA.Mask1;
uint32 address = (addr & ~PPU.VMA.Mask1) + (rem >> PPU.VMA.Shift) + ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3); uint32 address = (addr & ~PPU.VMA.Mask1) + (rem >> PPU.VMA.Shift) + ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3);
IPPU.VRAMReadBuffer = READ_WORD(Memory.VRAM + ((address << 1) & 0xffff)); PPU.VRAMReadBuffer = READ_WORD(Memory.VRAM + ((address << 1) & 0xffff));
} }
else else
IPPU.VRAMReadBuffer = READ_WORD(Memory.VRAM + ((PPU.VMA.Address << 1) & 0xffff)); PPU.VRAMReadBuffer = READ_WORD(Memory.VRAM + ((PPU.VMA.Address << 1) & 0xffff));
break; break;
@ -737,10 +737,10 @@ void S9xSetPPU (uint8 Byte, uint16 Address)
uint32 addr = PPU.VMA.Address; uint32 addr = PPU.VMA.Address;
uint32 rem = addr & PPU.VMA.Mask1; uint32 rem = addr & PPU.VMA.Mask1;
uint32 address = (addr & ~PPU.VMA.Mask1) + (rem >> PPU.VMA.Shift) + ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3); uint32 address = (addr & ~PPU.VMA.Mask1) + (rem >> PPU.VMA.Shift) + ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3);
IPPU.VRAMReadBuffer = READ_WORD(Memory.VRAM + ((address << 1) & 0xffff)); PPU.VRAMReadBuffer = READ_WORD(Memory.VRAM + ((address << 1) & 0xffff));
} }
else else
IPPU.VRAMReadBuffer = READ_WORD(Memory.VRAM + ((PPU.VMA.Address << 1) & 0xffff)); PPU.VRAMReadBuffer = READ_WORD(Memory.VRAM + ((PPU.VMA.Address << 1) & 0xffff));
break; break;
@ -1308,7 +1308,7 @@ uint8 S9xGetPPU (uint16 Address)
return (PPU.OpenBus1 = byte); return (PPU.OpenBus1 = byte);
case 0x2139: // VMDATALREAD case 0x2139: // VMDATALREAD
byte = IPPU.VRAMReadBuffer & 0xff; byte = PPU.VRAMReadBuffer & 0xff;
if (!PPU.VMA.High) if (!PPU.VMA.High)
{ {
if (PPU.VMA.FullGraphicCount) if (PPU.VMA.FullGraphicCount)
@ -1316,10 +1316,10 @@ uint8 S9xGetPPU (uint16 Address)
uint32 addr = PPU.VMA.Address; uint32 addr = PPU.VMA.Address;
uint32 rem = addr & PPU.VMA.Mask1; uint32 rem = addr & PPU.VMA.Mask1;
uint32 address = (addr & ~PPU.VMA.Mask1) + (rem >> PPU.VMA.Shift) + ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3); uint32 address = (addr & ~PPU.VMA.Mask1) + (rem >> PPU.VMA.Shift) + ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3);
IPPU.VRAMReadBuffer = READ_WORD(Memory.VRAM + ((address << 1) & 0xffff)); PPU.VRAMReadBuffer = READ_WORD(Memory.VRAM + ((address << 1) & 0xffff));
} }
else else
IPPU.VRAMReadBuffer = READ_WORD(Memory.VRAM + ((PPU.VMA.Address << 1) & 0xffff)); PPU.VRAMReadBuffer = READ_WORD(Memory.VRAM + ((PPU.VMA.Address << 1) & 0xffff));
PPU.VMA.Address += PPU.VMA.Increment; PPU.VMA.Address += PPU.VMA.Increment;
} }
@ -1330,7 +1330,7 @@ uint8 S9xGetPPU (uint16 Address)
return (PPU.OpenBus1 = byte); return (PPU.OpenBus1 = byte);
case 0x213a: // VMDATAHREAD case 0x213a: // VMDATAHREAD
byte = (IPPU.VRAMReadBuffer >> 8) & 0xff; byte = (PPU.VRAMReadBuffer >> 8) & 0xff;
if (PPU.VMA.High) if (PPU.VMA.High)
{ {
if (PPU.VMA.FullGraphicCount) if (PPU.VMA.FullGraphicCount)
@ -1338,10 +1338,10 @@ uint8 S9xGetPPU (uint16 Address)
uint32 addr = PPU.VMA.Address; uint32 addr = PPU.VMA.Address;
uint32 rem = addr & PPU.VMA.Mask1; uint32 rem = addr & PPU.VMA.Mask1;
uint32 address = (addr & ~PPU.VMA.Mask1) + (rem >> PPU.VMA.Shift) + ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3); uint32 address = (addr & ~PPU.VMA.Mask1) + (rem >> PPU.VMA.Shift) + ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3);
IPPU.VRAMReadBuffer = READ_WORD(Memory.VRAM + ((address << 1) & 0xffff)); PPU.VRAMReadBuffer = READ_WORD(Memory.VRAM + ((address << 1) & 0xffff));
} }
else else
IPPU.VRAMReadBuffer = READ_WORD(Memory.VRAM + ((PPU.VMA.Address << 1) & 0xffff)); PPU.VRAMReadBuffer = READ_WORD(Memory.VRAM + ((PPU.VMA.Address << 1) & 0xffff));
PPU.VMA.Address += PPU.VMA.Increment; PPU.VMA.Address += PPU.VMA.Increment;
} }
@ -2097,7 +2097,7 @@ void S9xSoftResetPPU (void)
memset(IPPU.TileCached[TILE_2BIT_ODD], 0, MAX_2BIT_TILES); memset(IPPU.TileCached[TILE_2BIT_ODD], 0, MAX_2BIT_TILES);
memset(IPPU.TileCached[TILE_4BIT_EVEN], 0, MAX_4BIT_TILES); memset(IPPU.TileCached[TILE_4BIT_EVEN], 0, MAX_4BIT_TILES);
memset(IPPU.TileCached[TILE_4BIT_ODD], 0, MAX_4BIT_TILES); memset(IPPU.TileCached[TILE_4BIT_ODD], 0, MAX_4BIT_TILES);
IPPU.VRAMReadBuffer = 0; // XXX: FIXME: anything better? PPU.VRAMReadBuffer = 0; // XXX: FIXME: anything better?
GFX.InterlaceFrame = 0; GFX.InterlaceFrame = 0;
IPPU.Interlace = FALSE; IPPU.Interlace = FALSE;
IPPU.InterlaceOBJ = FALSE; IPPU.InterlaceOBJ = FALSE;

3
ppu.h
View File

@ -227,7 +227,6 @@ struct InternalPPU
bool8 OBJChanged; bool8 OBJChanged;
uint8 *TileCache[7]; uint8 *TileCache[7];
uint8 *TileCached[7]; uint8 *TileCached[7];
uint16 VRAMReadBuffer;
bool8 Interlace; bool8 Interlace;
bool8 InterlaceOBJ; bool8 InterlaceOBJ;
bool8 PseudoHires; bool8 PseudoHires;
@ -378,6 +377,8 @@ struct SPPU
uint8 OpenBus1; uint8 OpenBus1;
uint8 OpenBus2; uint8 OpenBus2;
uint16 VRAMReadBuffer;
}; };
extern uint16 SignExtend[2]; extern uint16 SignExtend[2];

View File

@ -531,7 +531,8 @@ static FreezeData SnapPPU[] =
INT_ENTRY(6, HDMA), INT_ENTRY(6, HDMA),
INT_ENTRY(6, HDMAEnded), INT_ENTRY(6, HDMAEnded),
INT_ENTRY(6, OpenBus1), INT_ENTRY(6, OpenBus1),
INT_ENTRY(6, OpenBus2) INT_ENTRY(6, OpenBus2),
INT_ENTRY(11, VRAMReadBuffer)
}; };
#undef STRUCT #undef STRUCT