From 5e3426d0d26bb25810aca6593416ac0125ea6e8f Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Wed, 6 Feb 2013 19:07:39 -0500 Subject: Remove 320 KiB of memory allocations in APU emulation that were completely unused but constantly re-zeroed. Frees up 320 KiB for other uses, and saves ~4 milliseconds at emulator startup, when resetting the APU and when loading a new game. --- source/apu.cpp | 19 +------------------ source/apu.h | 2 -- source/nds/dma_adj.h | 3 +++ source/nds/entry.cpp | 1 - source/snes9x.h | 1 - 5 files changed, 4 insertions(+), 22 deletions(-) (limited to 'source') diff --git a/source/apu.cpp b/source/apu.cpp index d60cc75..769d2bc 100644 --- a/source/apu.cpp +++ b/source/apu.cpp @@ -116,18 +116,14 @@ void S9xTraceSoundDSP (const char *s, int i1 = 0, int i2 = 0, int i3 = 0, bool8 S9xInitAPU () { IAPU.RAM = (uint8 *) malloc (0x10000); - IAPU.ShadowRAM = (uint8 *) malloc (0x10000); - IAPU.CachedSamples = (uint8 *) malloc (0x40000); - if (!IAPU.RAM || !IAPU.ShadowRAM || !IAPU.CachedSamples) + if (!IAPU.RAM) { S9xDeinitAPU (); return (FALSE); } memset(IAPU.RAM, 0, 0x10000); - memset(IAPU.ShadowRAM, 0, 0x10000); - memset(IAPU.CachedSamples, 0, 0x40000); return (TRUE); } @@ -139,16 +135,6 @@ void S9xDeinitAPU () free ((char *) IAPU.RAM); IAPU.RAM = NULL; } - if (IAPU.ShadowRAM) - { - free ((char *) IAPU.ShadowRAM); - IAPU.ShadowRAM = NULL; - } - if (IAPU.CachedSamples) - { - free ((char *) IAPU.CachedSamples); - IAPU.CachedSamples = NULL; - } } EXTERN_C uint8 APUROM [64]; @@ -171,10 +157,7 @@ void S9xResetAPU () { memcpy(IAPU.RAM+(i<<8), IAPU.RAM, 0x100); } - - memcpy (IAPU.ShadowRAM, IAPU.RAM, 0x10000); - ZeroMemory (IAPU.CachedSamples, 0x40000); ZeroMemory (APU.OutPorts, 4); IAPU.DirectPage = IAPU.RAM; // memmove converted: Different mallocs [Neb] diff --git a/source/apu.h b/source/apu.h index 67b2525..b675dfd 100644 --- a/source/apu.h +++ b/source/apu.h @@ -104,8 +104,6 @@ struct SIAPU uint8 *WaitAddress1; uint8 *WaitAddress2; uint32 WaitCounter; - uint8 *ShadowRAM; - uint8 *CachedSamples; uint8 _Carry; uint8 _Zero; uint8 _Overflow; diff --git a/source/nds/dma_adj.h b/source/nds/dma_adj.h index 62b0098..dd4a6e4 100644 --- a/source/nds/dma_adj.h +++ b/source/nds/dma_adj.h @@ -8,7 +8,10 @@ extern "C" { #endif struct SPointerAdjustments { + /* These are used by the DSTWO-NDS side code. */ unsigned int GFXScreen; + + /* These are used by Snes9x. */ }; extern struct SPointerAdjustments PtrAdj; diff --git a/source/nds/entry.cpp b/source/nds/entry.cpp index 723374c..ae52ff0 100644 --- a/source/nds/entry.cpp +++ b/source/nds/entry.cpp @@ -432,7 +432,6 @@ void init_sfc_setting(void) Settings.ShutdownMaster = TRUE; Settings.FrameTimePAL = 20000; Settings.FrameTimeNTSC = 16667; - Settings.DisableSampleCaching = FALSE; Settings.DisableMasterVolume = FALSE; Settings.Mouse = TRUE; Settings.SuperScope = TRUE; diff --git a/source/snes9x.h b/source/snes9x.h index 6c93855..2661923 100644 --- a/source/snes9x.h +++ b/source/snes9x.h @@ -341,7 +341,6 @@ struct SSettings{ int SoundMixInterval; bool8 SoundEnvelopeHeightReading; bool8 DisableSoundEcho; - bool8 DisableSampleCaching; bool8 DisableMasterVolume; bool8 SoundSync; bool8 InterpolatedSound; -- cgit v1.2.3