From 616ea0c4c68ac5ee90c1fc835d047bdbd3da62a3 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Wed, 29 Oct 2014 10:24:58 +0100 Subject: cleanups. --- source/globals.c | 3 --- source/memmap.c | 27 +++++++++++++-------------- source/memmap.h | 3 --- source/snaporig.c | 2 +- source/snapshot.c | 8 ++++---- 5 files changed, 18 insertions(+), 25 deletions(-) diff --git a/source/globals.c b/source/globals.c index 3a4dc4b..caf3ee0 100644 --- a/source/globals.c +++ b/source/globals.c @@ -127,9 +127,6 @@ SnesModel M2SNES={2,4,3}; SnesModel* Model=&M1SNES; -uint8 *SRAM_g = NULL; -uint8 *ROM_g = NULL; -uint8 *RegRAM_g = NULL; uint8 *C4RAM = NULL; long OpAddress = 0; diff --git a/source/memmap.c b/source/memmap.c index 598bae3..38411c2 100644 --- a/source/memmap.c +++ b/source/memmap.c @@ -463,9 +463,8 @@ bool8 Init () Memory.ROM += 0x8000; // still 32-byte aligned Memory.C4RAM = Memory.ROM + 0x400000 + 8192 * 8; // still 32-byte aligned - ROM_g = Memory.ROM; - SRAM_g = Memory.SRAM; - RegRAM_g = Memory.FillRAM; + Memory.ROM = Memory.ROM; + Memory.SRAM = Memory.SRAM; #ifdef ZSNES_FX SFXPlotTable = ROM + 0x400000; @@ -1309,7 +1308,7 @@ void InitROM (bool8 Interleaved) ZeroMemory (Memory.BlockIsRAM, MEMMAP_NUM_BLOCKS); ZeroMemory (Memory.BlockIsROM, MEMMAP_NUM_BLOCKS); - SRAM_g = Memory.SRAM; + Memory.SRAM = Memory.SRAM; memset (Memory.ROMId, 0, 5); memset (Memory.CompanyId, 0, 3); @@ -1632,13 +1631,13 @@ bool8 LoadSRAM (const char *filename) FILE *file; if ((file = fopen (filename, "rb"))) { - int len = fread ((unsigned char*) SRAM_g, 1, 0x20000, file); + int len = fread ((unsigned char*) Memory.SRAM, 1, 0x20000, file); fclose (file); if (len - size == 512) { // S-RAM file has a header - remove it // memmove required: Overlapping addresses [Neb] - memmove (SRAM_g, SRAM_g + 512, size); + memmove (Memory.SRAM, Memory.SRAM + 512, size); } if (len == size + SRTC_SRAM_PAD) { @@ -1693,7 +1692,7 @@ bool8 SaveSRAM (const char *filename) FILE *file= fopen(filename, "w"); if (file) { - fwrite((unsigned char *) SRAM_g, size, 1, file); + fwrite((unsigned char *) Memory.SRAM, size, 1, file); fclose(file); if(Settings.SPC7110RTC) { @@ -1811,10 +1810,10 @@ void MapExtraRAM () // Banks 70->73, S-RAM for (c = 0; c < 16; c++) { - Memory.Map [c + 0x700] = SRAM_g; - Memory.Map [c + 0x710] = SRAM_g + 0x8000; - Memory.Map [c + 0x720] = SRAM_g + 0x10000; - Memory.Map [c + 0x730] = SRAM_g + 0x18000; + Memory.Map [c + 0x700] = Memory.SRAM; + Memory.Map [c + 0x710] = Memory.SRAM + 0x8000; + Memory.Map [c + 0x720] = Memory.SRAM + 0x10000; + Memory.Map [c + 0x730] = Memory.SRAM + 0x18000; Memory.BlockIsRAM [c + 0x700] = TRUE; Memory.BlockIsROM [c + 0x700] = FALSE; @@ -2538,8 +2537,8 @@ void SuperFXROMMap () Memory.Map [c + 3] = Memory.Map [c + 0x803] = (uint8 *) MAP_PPU; Memory.Map [c + 4] = Memory.Map [c + 0x804] = (uint8 *) MAP_CPU; Memory.Map [c + 5] = Memory.Map [c + 0x805] = (uint8 *) MAP_CPU; - Memory.Map [0x006 + c] = Memory.Map [0x806 + c] = (uint8 *) SRAM_g - 0x6000; - Memory.Map [0x007 + c] = Memory.Map [0x807 + c] = (uint8 *) SRAM_g - 0x6000; + Memory.Map [0x006 + c] = Memory.Map [0x806 + c] = (uint8 *) Memory.SRAM - 0x6000; + Memory.Map [0x007 + c] = Memory.Map [0x807 + c] = (uint8 *) Memory.SRAM - 0x6000; Memory.BlockIsRAM [0x006 + c] = Memory.BlockIsRAM [0x007 + c] = Memory.BlockIsRAM [0x806 + c] = Memory.BlockIsRAM [0x807 + c] = TRUE; for (i = c + 8; i < c + 16; i++) @@ -2573,7 +2572,7 @@ void SuperFXROMMap () // Banks 70->71, S-RAM for (c = 0; c < 32; c++) { - Memory.Map [c + 0x700] = SRAM_g + (((c >> 4) & 1) << 16); + Memory.Map [c + 0x700] = Memory.SRAM + (((c >> 4) & 1) << 16); Memory.BlockIsRAM [c + 0x700] = TRUE; Memory.BlockIsROM [c + 0x700] = FALSE; } diff --git a/source/memmap.h b/source/memmap.h index 4ea48c0..2d83852 100644 --- a/source/memmap.h +++ b/source/memmap.h @@ -246,9 +246,6 @@ typedef struct void ResetSpeedMap(); extern CMemory Memory; -extern uint8 *SRAM_g; -extern uint8 *ROM_g; -extern uint8 *RegRAM_g; void S9xDeinterleaveMode2 (); bool8 LoadZip(const char* zipname, int32 *TotalFileSize, diff --git a/source/snaporig.c b/source/snaporig.c index fbea9c7..8e97028 100644 --- a/source/snaporig.c +++ b/source/snaporig.c @@ -370,7 +370,7 @@ static int ReadOrigSnapshot (STREAM snap) return (result); if ((result = ReadBlock ("RAM:", Memory.RAM, 0x20000, snap)) != SUCCESS) return (result); - if ((result = ReadBlock ("SRA:", SRAM_g, 0x10000, snap)) != SUCCESS) + if ((result = ReadBlock ("SRA:", Memory.SRAM, 0x10000, snap)) != SUCCESS) return (result); if ((result = ReadBlock ("FIL:", Memory.FillRAM, 0x8000, snap)) != SUCCESS) return (result); diff --git a/source/snapshot.c b/source/snapshot.c index df64a1c..88b2ec7 100644 --- a/source/snapshot.c +++ b/source/snapshot.c @@ -660,7 +660,7 @@ void S9xFreezeToStream (STREAM stream) // RAM and VRAM FreezeBlock (stream, "VRA", Memory.VRAM, 0x10000); FreezeBlock (stream, "RAM", Memory.RAM, 0x20000); - FreezeBlock (stream, "SRA", SRAM_g, 0x20000); + FreezeBlock (stream, "SRA", Memory.SRAM, 0x20000); FreezeBlock (stream, "FIL", Memory.FillRAM, 0x8000); if (Settings.APUEnabled) { @@ -803,7 +803,7 @@ int S9xUnfreezeFromStream (STREAM stream) UnfreezeStructFromCopy (DMA, SnapDMA, COUNT (SnapDMA), local_dma); memcpy (Memory.VRAM, local_vram, 0x10000); memcpy (Memory.RAM, local_ram, 0x20000); - memcpy (SRAM_g, local_sram, 0x20000); + memcpy (Memory.SRAM, local_sram, 0x20000); memcpy (Memory.FillRAM, local_fillram, 0x8000); if(local_apu) { @@ -1585,7 +1585,7 @@ bool8 S9xUnfreezeZSNES (const char *filename) if (Settings.SuperFX) { - fread (SRAM_g, 1, 64 * 1024, fs); + fread (Memory.SRAM, 1, 64 * 1024, fs); fseek (fs, 64 * 1024, SEEK_CUR); fread (Memory.FillRAM + 0x7000, 1, 692, fs); } @@ -1617,7 +1617,7 @@ bool8 S9xUnfreezeZSNES (const char *filename) // DS2 DMA notes: This code path is not used [Neb] memcpy (&Memory.FillRAM [0x3000], t + 692, 2 * 1024); - fread (SRAM_g, 1, 64 * 1024, fs); + fread (Memory.SRAM, 1, 64 * 1024, fs); fseek (fs, 64 * 1024, SEEK_CUR); S9xFixSA1AfterSnapshotLoad (); } -- cgit v1.2.3