Merge pull request #626 from bbbradsmith/ppu_internal_memory_init

Memory initialization settings for PPU internal memory
This commit is contained in:
thor2016 2023-05-04 20:58:47 -04:00 committed by GitHub
commit 94f2696a83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 4 deletions

View File

@ -1734,10 +1734,17 @@ void FCEUPPU_Reset(void) {
void FCEUPPU_Power(void) {
int x;
memset(NTARAM, 0x00, 0x800);
memset(PALRAM, 0x00, 0x20);
memset(UPALRAM, 0x00, 0x03);
memset(SPRAM, 0x00, 0x100);
// initialize PPU memory regions according to settings
FCEU_MemoryRand(NTARAM, 0x800, true);
FCEU_MemoryRand(PALRAM, 0x20, true);
FCEU_MemoryRand(SPRAM, 0x100, true);
// palettes can only store values up to $3F, and PALRAM X4/X8/XC are mirrors of X0 for rendering purposes (UPALRAM is used for $2007 readback)
for (x = 0; x < 0x20; ++x) PALRAM[x] &= 0x3F;
UPALRAM[0] = PALRAM[0x04];
UPALRAM[1] = PALRAM[0x08];
UPALRAM[2] = PALRAM[0x0C];
PALRAM[0x0C] = PALRAM[0x08] = PALRAM[0x04] = PALRAM[0x00];
PALRAM[0x1C] = PALRAM[0x18] = PALRAM[0x14] = PALRAM[0x10];
FCEUPPU_Reset();
for (x = 0x2000; x < 0x4000; x += 8) {