Make SRAM and GFX.Screen dynamic again.

This commit is contained in:
BearOso 2023-03-23 19:02:23 -05:00
parent fdcef11795
commit d948ef8a19
4 changed files with 9 additions and 4 deletions

View File

@ -54,6 +54,7 @@ bool8 S9xGraphicsInit (void)
S9xFixColourBrightness();
S9xBuildDirectColourMaps();
GFX.ScreenBuffer.resize(MAX_SNES_WIDTH * (MAX_SNES_HEIGHT + 64));
GFX.Screen = &GFX.ScreenBuffer[GFX.RealPPL * 32];
GFX.ZERO = (uint16 *) malloc(sizeof(uint16) * 0x10000);
GFX.SubScreen = (uint16 *) malloc(GFX.ScreenSize * sizeof(uint16));

3
gfx.h
View File

@ -8,13 +8,14 @@
#define _GFX_H_
#include "port.h"
#include <vector>
struct SGFX
{
const uint32 Pitch = sizeof(uint16) * MAX_SNES_WIDTH;
const uint32 RealPPL = MAX_SNES_WIDTH; // true PPL of Screen buffer
const uint32 ScreenSize = MAX_SNES_WIDTH * MAX_SNES_HEIGHT;
uint16 ScreenBuffer[MAX_SNES_WIDTH * (MAX_SNES_HEIGHT + 64)];
std::vector<uint16> ScreenBuffer;
uint16 *Screen;
uint16 *SubScreen;
uint8 *ZBuffer;

View File

@ -929,10 +929,12 @@ bool8 CMemory::Init (void)
}
ROMStorage.resize(MAX_ROM_SIZE + 0x200 + 0x8000);
std::fill(ROMStorage.begin(), ROMStorage.end(), 0);
SRAMStorage.resize(0x80000);
std::fill(SRAMStorage.begin(), SRAMStorage.end(), 0);
SRAM = &SRAMStorage[0];
memset(RAM, 0, sizeof(RAM));
memset(SRAM, 0, sizeof(SRAM));
memset(VRAM, 0, sizeof(VRAM));
memset(ROMStorage.data(), 0, ROMStorage.size());
memset(IPPU.TileCache[TILE_2BIT], 0, MAX_2BIT_TILES * 64);
memset(IPPU.TileCache[TILE_4BIT], 0, MAX_4BIT_TILES * 64);

View File

@ -59,7 +59,8 @@ struct CMemory
uint8 RAM[0x20000];
std::vector<uint8_t> ROMStorage;
uint8 *ROM;
uint8 SRAM[0x80000];
std::vector<uint8_t> SRAMStorage;
uint8 *SRAM;
uint8 VRAM[0x10000];
uint8 *FillRAM;
uint8 *BWRAM;