From 7077e9821593b2c9b78830c4cc5055c6a79cdd69 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Mon, 3 Nov 2014 11:11:05 +0100 Subject: can build with USE_BLARGG_APU enabled, still not working. --- source/apu.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ source/apu_blargg.c | 8 ++++++-- source/cpuexec.c | 11 +++++++++++ source/cpuops.c | 4 ++++ source/dma.c | 3 ++- source/globals.c | 9 ++++++--- source/memmap.c | 6 +++++- source/ppu.c | 5 ++++- source/snes9x.h | 3 +++ 9 files changed, 86 insertions(+), 8 deletions(-) (limited to 'source') diff --git a/source/apu.h b/source/apu.h index 046749d..59c8aeb 100644 --- a/source/apu.h +++ b/source/apu.h @@ -210,5 +210,50 @@ extern void (*S9xApuOpcodes [256])(void); #define FREQUENCY_MASK 0x3fff #endif +#else +#include "apu_blargg.h" +#define ONE_APU_CYCLE 21 +#define APU_EXECUTE1() do{}while(0) +#define APU_EXECUTE() do{}while(0) + +//typedef struct +//{ +// uint8* PC; +// SAPURegisters Registers; +// uint8* RAM; +// uint8* DirectPage; +// bool8 APUExecuting; +// uint8 Bit; +// uint32 Address; +// uint8* WaitAddress1; +// uint8* WaitAddress2; +// uint32 WaitCounter; +// uint8 _Carry; +// uint8 _Zero; +// uint8 _Overflow; +// uint32 TimerErrorCounter; +// uint32 Scanline; +// int32 OneCycle; +// int32 TwoCycles; +//} SIAPU; + +//typedef struct +//{ +// int32 Cycles; +// bool8 ShowROM; +// uint8 Flags; +// uint8 KeyedChannels; +// uint8 OutPorts [4]; +// uint8 DSP [0x80]; +// uint8 ExtraRAM [64]; +// uint16 Timer [3]; +// uint16 TimerTarget [3]; +// bool8 TimerEnabled [3]; +// bool8 TimerValueWritten [3]; +//} SAPU; + +//SAPU APU; +//SIAPU IAPU; + #endif diff --git a/source/apu_blargg.c b/source/apu_blargg.c index c2afa9b..78b4c25 100644 --- a/source/apu_blargg.c +++ b/source/apu_blargg.c @@ -182,12 +182,16 @@ #include #include "blargg_endian.h" -#include "apu.h" +#include "apu_blargg.h" #include "snes9x.h" -#include "snapshot.h" +//#include "snapshot.h" #include "display.h" +#ifndef INLINE +#define INLINE inline +#endif + /*********************************************************************************** SPC DSP ***********************************************************************************/ diff --git a/source/cpuexec.c b/source/cpuexec.c index 2c1b67a..ce2d5c3 100644 --- a/source/cpuexec.c +++ b/source/cpuexec.c @@ -612,6 +612,8 @@ void S9xDoHBlankProcessing_SFX() if (CPU.V_Counter >= FIRST_VISIBLE_LINE && CPU.V_Counter < PPU.ScreenHeight + FIRST_VISIBLE_LINE) RenderLine(CPU.V_Counter - FIRST_VISIBLE_LINE); + +#ifndef USE_BLARGG_APU // Use TimerErrorCounter to skip update of SPC700 timers once // every 128 updates. Needed because this section of code is called // once every emulated 63.5 microseconds, which coresponds to @@ -665,6 +667,7 @@ void S9xDoHBlankProcessing_SFX() } } } +#endif // #ifndef USE_BLARGG_APU break; case HTIMER_BEFORE_EVENT: @@ -700,6 +703,7 @@ void S9xDoHBlankProcessing_NoSFX() case HBLANK_END_EVENT: +#ifndef USE_BLARGG_APU #ifndef STORM if (Settings.SoundSync) S9xGenerateSound(); @@ -715,6 +719,11 @@ void S9xDoHBlankProcessing_NoSFX() } else APU.Cycles = 0; +#else + S9xAPUExecute(); + CPU.Cycles -= Settings.H_Max; + S9xAPUSetReferenceTime(CPU.Cycles); +#endif CPU.NextEvent = -1; ICPU.Scanline++; @@ -804,6 +813,7 @@ void S9xDoHBlankProcessing_NoSFX() // if (IAPU.TimerErrorCounter >= ) // IAPU.TimerErrorCounter = 0; // else +#ifndef USE_BLARGG_APU { if (APU.TimerEnabled [2]) { @@ -848,6 +858,7 @@ void S9xDoHBlankProcessing_NoSFX() } } } +#endif break; case HTIMER_BEFORE_EVENT: diff --git a/source/cpuops.c b/source/cpuops.c index 83b6910..f398e0c 100644 --- a/source/cpuops.c +++ b/source/cpuops.c @@ -3383,6 +3383,7 @@ static inline void CPUShutdown() CPU.WaitAddress = NULL; if (Settings.SA1) S9xSA1ExecuteDuringSleep(); +#ifndef USE_BLARGG_APU CPU.Cycles = CPU.NextEvent; if (IAPU.APUExecuting) { @@ -3394,6 +3395,7 @@ static inline void CPUShutdown() while (APU.Cycles < CPU.NextEvent); ICPU.CPUExecuting = TRUE; } +#endif } else if (CPU.WaitCounter >= 2) CPU.WaitCounter = 1; @@ -4980,6 +4982,7 @@ static void OpCB(void) if (Settings.Shutdown) { CPU.Cycles = CPU.NextEvent; +#ifndef USE_BLARGG_APU if (IAPU.APUExecuting) { ICPU.CPUExecuting = FALSE; @@ -4990,6 +4993,7 @@ static void OpCB(void) while (APU.Cycles < CPU.NextEvent); ICPU.CPUExecuting = TRUE; } +#endif } else { diff --git a/source/dma.c b/source/dma.c index a5e4a35..f02d10a 100644 --- a/source/dma.c +++ b/source/dma.c @@ -811,10 +811,11 @@ void S9xDoDMA(uint8 Channel) } while (count); } - +#ifndef USE_BLARGG_APU #ifdef SPC700_C IAPU.APUExecuting = Settings.APUEnabled; APU_EXECUTE(); +#endif #endif if (Settings.SuperFX) while (CPU.Cycles > CPU.NextEvent) diff --git a/source/globals.c b/source/globals.c index e2c9d7c..3303dca 100644 --- a/source/globals.c +++ b/source/globals.c @@ -110,9 +110,11 @@ SICPU ICPU; SCPUState CPU; +#ifndef USE_BLARGG_APU SAPU APU; - SIAPU IAPU; +SSoundData SoundData; +#endif SSettings Settings; @@ -120,7 +122,7 @@ SDSP1 DSP1; SSA1 SA1; -SSoundData SoundData; + SnesModel M1SNES = {1, 3, 2}; SnesModel M2SNES = {2, 4, 3}; @@ -169,6 +171,7 @@ uint32 even_low[4][16]; SCheatData Cheat; #endif +#ifndef USE_BLARGG_APU SoundStatus so; int Echo [24000]; @@ -178,7 +181,7 @@ int EchoBuffer [SOUND_BUFFER_SIZE]; int FilterTaps [8]; unsigned long Z = 0; int Loop [16]; - +#endif uint16 SignExtend [2] = { 0x00, 0xff00 diff --git a/source/memmap.c b/source/memmap.c index 587a2c2..60e190a 100644 --- a/source/memmap.c +++ b/source/memmap.c @@ -1455,7 +1455,9 @@ void InitROM(bool8 Interleaved) } } +#ifndef USE_BLARGG_APU IAPU.OneCycle = ONE_APU_CYCLE; +#endif Settings.Shutdown = Settings.ShutdownMaster; SetDSP = &DSP1SetByte; @@ -3714,6 +3716,7 @@ void ApplyROMFixes() //APU timing hacks +#ifndef USE_BLARGG_APU // Stunt Racer FX if (strcmp(Memory.ROMId, "CQ ") == 0 || // Illusion of Gaia @@ -3721,6 +3724,7 @@ void ApplyROMFixes() strcmp(Memory.ROMName, "GAIA GENSOUKI 1 JPN") == 0) IAPU.OneCycle = 13; + // RENDERING RANGER R2 if (strcmp(Memory.ROMId, "AVCJ") == 0 || //Mark Davis @@ -3768,7 +3772,7 @@ void ApplyROMFixes() || //Kamen Rider strncmp(Memory.ROMName, "LETs PACHINKO(", 14) == 0) //A set of BS games IAPU.OneCycle = 15; - +#endif //Specific game fixes diff --git a/source/ppu.c b/source/ppu.c index 181fdaf..bc28114 100644 --- a/source/ppu.c +++ b/source/ppu.c @@ -886,6 +886,7 @@ void S9xSetPPU(uint8 Byte, uint16 Address) case 0x217d: case 0x217e: case 0x217f: +#ifndef USE_BLARGG_APU #ifdef SPCTOOL _SPCInPB(Address & 3, Byte); #else @@ -897,6 +898,7 @@ void S9xSetPPU(uint8 Byte, uint16 Address) IAPU.WaitCounter++; #endif #endif // SPCTOOL +#endif // #ifndef USE_BLARGG_APU break; case 0x2180: REGISTER_2180(Byte); @@ -1269,6 +1271,7 @@ uint8 S9xGetPPU(uint16 Address) case 0x217d: case 0x217e: case 0x217f: +#ifndef USE_BLARGG_APU #ifdef SPCTOOL return ((uint8) _SPCOutP [Address & 3]); #else @@ -1291,7 +1294,7 @@ uint8 S9xGetPPU(uint16 Address) return (APU.OutPorts [Address & 3]); } - +#endif switch (Settings.SoundSkipMethod) { case 0: diff --git a/source/snes9x.h b/source/snes9x.h index 48a5714..e9c04a5 100644 --- a/source/snes9x.h +++ b/source/snes9x.h @@ -322,6 +322,9 @@ typedef struct bool8 OBC1; /* Sound options */ uint32 SoundPlaybackRate; +#ifdef USE_BLARGG_APU + uint32 SoundInputRate; +#endif bool8 TraceSoundDSP; bool8 EightBitConsoleSound; // due to caching, this needs S9xSetEightBitConsoleSound() int SoundBufferSize; -- cgit v1.2.3