diff options
author | João Silva | 2017-01-16 22:39:57 +0000 |
---|---|---|
committer | João Silva | 2017-01-16 22:39:57 +0000 |
commit | cbbfa871ae3d9db3852d9122a6d8355896c073ed (patch) | |
tree | 73e7755d117b8dd9eea499977c632727deb20d00 /source | |
parent | 7ed90abe19954aaf1fa56657a08e3cae4c8a67ce (diff) | |
download | snes9x2005-cbbfa871ae3d9db3852d9122a6d8355896c073ed.tar.gz snes9x2005-cbbfa871ae3d9db3852d9122a6d8355896c073ed.tar.bz2 snes9x2005-cbbfa871ae3d9db3852d9122a6d8355896c073ed.zip |
Many cleanups.
Diffstat (limited to 'source')
59 files changed, 655 insertions, 1409 deletions
diff --git a/source/65c816.h b/source/65c816.h index 5b6184f..f180037 100644 --- a/source/65c816.h +++ b/source/65c816.h @@ -70,6 +70,7 @@ typedef union uint8_t l, h; } B; #endif + uint16_t W; } pair; @@ -77,14 +78,13 @@ typedef struct { uint8_t PB; uint8_t DB; - pair P; - pair A; - pair D; - pair S; - pair X; - pair Y; + pair P; + pair A; + pair D; + pair S; + pair X; + pair Y; uint16_t PC; } SRegisters; #endif - diff --git a/source/apu.c b/source/apu.c index 91453e6..500a884 100644 --- a/source/apu.c +++ b/source/apu.c @@ -422,19 +422,19 @@ void S9xFixEnvelope(int channel, uint8_t gain, uint8_t adsr1, uint8_t adsr2) // ADSR mode static unsigned long AttackRate [16] = { - 4100, 2600, 1500, 1000, 640, 380, 260, 160, - 96, 64, 40, 24, 16, 10, 6, 1 + 4100u, 2600u, 1500u, 1000u, 640u, 380u, 260u, 160u, + 96u, 64u, 40u, 24u, 16u, 10u, 6u, 1u }; static unsigned long DecayRate [8] = { - 1200, 740, 440, 290, 180, 110, 74, 37 + 1200u, 740u, 440u, 290u, 180u, 110u, 74u, 37u }; static unsigned long SustainRate [32] = { - ~0, 38000, 28000, 24000, 19000, 14000, 12000, 9400, - 7100, 5900, 4700, 3500, 2900, 2400, 1800, 1500, - 1200, 880, 740, 590, 440, 370, 290, 220, - 180, 150, 110, 92, 74, 55, 37, 18 + ~0u, 38000u, 28000u, 24000u, 19000u, 14000u, 12000u, 9400u, + 7100u, 5900u, 4700u, 3500u, 2900u, 2400u, 1800u, 1500u, + 1200u, 880u, 740u, 590u, 440u, 370u, 290u, 220u, + 180u, 150u, 110u, 92u, 74u, 55u, 37u, 18u }; // XXX: can DSP be switched to ADSR mode directly from GAIN/INCREASE/ // DECREASE mode? And if so, what stage of the sequence does it start @@ -470,17 +470,17 @@ void S9xFixEnvelope(int channel, uint8_t gain, uint8_t adsr1, uint8_t adsr2) { static unsigned long IncreaseRate [32] = { - ~0, 4100, 3100, 2600, 2000, 1500, 1300, 1000, - 770, 640, 510, 380, 320, 260, 190, 160, - 130, 96, 80, 64, 48, 40, 32, 24, - 20, 16, 12, 10, 8, 6, 4, 2 + ~0u, 4100u, 3100u, 2600u, 2000u, 1500u, 1300u, 1000u, + 770u, 640u, 510u, 380u, 320u, 260u, 190u, 160u, + 130u, 96u, 80u, 64u, 48u, 40u, 32u, 24u, + 20u, 16u, 12u, 10u, 8u, 6u, 4u, 2u }; static unsigned long DecreaseRateExp [32] = { - ~0, 38000, 28000, 24000, 19000, 14000, 12000, 9400, - 7100, 5900, 4700, 3500, 2900, 2400, 1800, 1500, - 1200, 880, 740, 590, 440, 370, 290, 220, - 180, 150, 110, 92, 74, 55, 37, 18 + ~0u, 38000u, 28000u, 24000u, 19000u, 14000u, 12000u, 9400u, + 7100u, 5900u, 4700u, 3500u, 2900u, 2400u, 1800u, 1500u, + 1200u, 880u, 740u, 590u, 440u, 370u, 290u, 220u, + 180u, 150u, 110u, 92u, 74u, 55u, 37u, 18u }; if (gain & 0x40) { diff --git a/source/apu.h b/source/apu.h index d5cdc78..3f88346 100644 --- a/source/apu.h +++ b/source/apu.h @@ -10,29 +10,29 @@ typedef struct { - uint8_t* PC; + uint8_t* PC; SAPURegisters Registers; - uint8_t* RAM; - uint8_t* DirectPage; - bool APUExecuting; - uint8_t Bit; - uint32_t Address; - uint8_t* WaitAddress1; - uint8_t* WaitAddress2; - uint32_t WaitCounter; - uint8_t _Carry; - uint8_t _Zero; - uint8_t _Overflow; - uint32_t TimerErrorCounter; - uint32_t Scanline; - int32_t OneCycle; - int32_t TwoCycles; + uint8_t* RAM; + uint8_t* DirectPage; + bool APUExecuting; + uint8_t Bit; + uint32_t Address; + uint8_t* WaitAddress1; + uint8_t* WaitAddress2; + uint32_t WaitCounter; + uint8_t _Carry; + uint8_t _Zero; + uint8_t _Overflow; + uint32_t TimerErrorCounter; + uint32_t Scanline; + int32_t OneCycle; + int32_t TwoCycles; } SIAPU; typedef struct { int32_t Cycles; - bool ShowROM; + bool ShowROM; uint8_t Flags; uint8_t KeyedChannels; uint8_t OutPorts [4]; @@ -40,8 +40,8 @@ typedef struct uint8_t ExtraRAM [64]; uint16_t Timer [3]; uint16_t TimerTarget [3]; - bool TimerEnabled [3]; - bool TimerValueWritten [3]; + bool TimerEnabled [3]; + bool TimerValueWritten [3]; } SAPU; SAPU APU; @@ -78,7 +78,6 @@ extern uint16_t S9xAPUCycles [256]; // Scaled cycle lengths extern uint16_t S9xAPUCycleLengths [256]; // Raw data. extern void (*S9xApuOpcodes [256])(void); - #define APU_VOL_LEFT 0x00 #define APU_VOL_RIGHT 0x01 #define APU_P_LOW 0x02 @@ -130,4 +129,3 @@ extern void (*S9xApuOpcodes [256])(void); #define APU_EXECUTE() do{}while(0) #endif - diff --git a/source/apu_blargg.h b/source/apu_blargg.h index 6c44acc..f2a89ec 100644 --- a/source/apu_blargg.h +++ b/source/apu_blargg.h @@ -82,36 +82,25 @@ typedef void (*dsp_copy_func_t)( unsigned char** io, void* state, size_t ); typedef struct { - /* decoded samples (twice the size to simplify wrap handling) */ - int buf [BRR_BUF_SIZE_X2]; - /* place in buffer where next samples will be decoded */ - int buf_pos; - /* relative fractional position in sample (0x1000 = 1.0) */ - int interp_pos; - /* address of current BRR block */ - int brr_addr; - /* current decoding offset in BRR block */ - int brr_offset; - /* pointer to voice's DSP registers */ - uint8_t* regs; - /* bitmask for voice: 0x01 for voice 0, 0x02 for voice 1, etc. */ - int vbit; - /* KON delay/current setup phase */ - int kon_delay; - int env_mode; - /* current envelope level */ - int env; - /* used by GAIN mode 7, very obscure quirk */ - int hidden_env; - uint8_t t_envx_out; + int buf [BRR_BUF_SIZE_X2]; // decoded samples (twice the size to simplify wrap handling) + int buf_pos; // place in buffer where next samples will be decoded + int interp_pos; // relative fractional position in sample (0x1000 = 1.0) + int brr_addr; // address of current BRR block + int brr_offset; // current decoding offset in BRR block + uint8_t* regs; // pointer to voice's DSP registers + int vbit; // bitmask for voice: 0x01 for voice 0, 0x02 for voice 1, etc. + int kon_delay; // KON delay/current setup phase + int env_mode; + int env; // current envelope level + int hidden_env; // used by GAIN mode 7, very obscure quirk + uint8_t t_envx_out; } dsp_voice_t; typedef struct { uint8_t regs [REGISTER_COUNT]; - /* Echo history keeps most recent 8 samples - (twice the size to simplify wrap handling) */ + /* Echo history keeps most recent 8 samples (twice the size to simplify wrap handling) */ int echo_hist [ECHO_HIST_SIZE_X2] [2]; @@ -126,7 +115,7 @@ typedef struct int phase; /* next clock cycle to run (0-31) */ /* Hidden registers also written to when main register is written to */ - int new_kon; + int new_kon; uint8_t endx_buf; uint8_t envx_buf; uint8_t outx_buf; @@ -168,10 +157,11 @@ typedef struct int16_t* out; int16_t* out_end; int16_t* out_begin; - int16_t extra [EXTRA_SIZE]; + int16_t extra [EXTRA_SIZE]; - int rom_enabled; - uint8_t *rom, *hi_ram; + int rom_enabled; + uint8_t *rom; + uint8_t *hi_ram; } dsp_state_t; #if !SPC_NO_COPY_STATE_FUNCS @@ -254,20 +244,20 @@ typedef struct int sp; } cpu_regs; - int dsp_time; - int spc_time; + int dsp_time; + int spc_time; - int tempo; + int tempo; - int extra_clocks; - int16_t* buf_begin; + int extra_clocks; + int16_t* buf_begin; int16_t* buf_end; - int16_t* extra_pos; - int16_t extra_buf [EXTRA_SIZE]; + int16_t* extra_pos; + int16_t extra_buf [EXTRA_SIZE]; - int rom_enabled; - uint8_t rom [ROM_SIZE]; - uint8_t hi_ram [ROM_SIZE]; + int rom_enabled; + uint8_t rom [ROM_SIZE]; + uint8_t hi_ram [ROM_SIZE]; unsigned char cycle_table [256]; @@ -275,7 +265,7 @@ typedef struct { /* padding to neutralize address overflow */ union { - uint8_t padding1 [0x100]; + uint8_t padding1 [0x100]; uint16_t align; /* makes compiler align data for 16-bit access */ } padding1 [1]; uint8_t ram [0x10000]; diff --git a/source/apumem.h b/source/apumem.h index c86b8c0..74594d6 100644 --- a/source/apumem.h +++ b/source/apumem.h @@ -132,4 +132,3 @@ INLINE void S9xAPUSetByte(uint8_t byte, uint32_t Address) } } #endif - diff --git a/source/c4.c b/source/c4.c index 163341b..65d4c01 100644 --- a/source/c4.c +++ b/source/c4.c @@ -136,14 +136,3 @@ void C4Op0D() C41FYVal = (int16_t)(C41FYVal * tanval * 0.99); C41FXVal = (int16_t)(C41FXVal * tanval * 0.98); } - -#ifdef ZSNES_C4 -void C4LoaDMem(char* C4RAM) -{ - memmove(C4RAM + (READ_WORD(C4RAM + 0x1f45) & 0x1fff), - S9xGetMemPointer(READ_3WORD(C4RAM + 0x1f40)), - READ_WORD(C4RAM + 0x1f43)); -} -#endif - - diff --git a/source/c4.h b/source/c4.h index 7834776..590ead0 100644 --- a/source/c4.h +++ b/source/c4.h @@ -31,4 +31,3 @@ extern int16_t C4CosTable[]; extern int16_t C4SinTable[]; #endif - diff --git a/source/c4emu.c b/source/c4emu.c index 6fce00f..06cdfe3 100644 --- a/source/c4emu.c +++ b/source/c4emu.c @@ -857,4 +857,3 @@ int16_t C4CosTable[512] = 32138, 32214, 32285, 32351, 32413, 32469, 32521, 32568, 32610, 32647, 32679, 32706, 32728, 32745, 32758, 32765 }; - diff --git a/source/cheats.h b/source/cheats.h index 86d4f96..a4a5ba7 100644 --- a/source/cheats.h +++ b/source/cheats.h @@ -13,26 +13,25 @@ typedef struct uint32_t address; uint8_t byte; uint8_t saved_byte; - bool enabled; - bool saved; - char name[MAX_SFCCHEAT_NAME]; -}SCheat; - + bool enabled; + bool saved; + char name[MAX_SFCCHEAT_NAME]; +} SCheat; typedef struct { SCheat c [MAX_CHEATS_T]; - uint32_t num_cheats; - uint8_t CWRAM [0x20000]; - uint8_t CSRAM [0x10000]; - uint8_t CIRAM [0x2000]; - uint8_t *RAM; - uint8_t *FillRAM; - uint8_t *SRAM; - uint32_t WRAM_BITS [0x20000 >> 3]; - uint32_t SRAM_BITS [0x10000 >> 3]; - uint32_t IRAM_BITS [0x2000 >> 3]; -}SCheatData; + uint32_t num_cheats; + uint8_t CWRAM [0x20000]; + uint8_t CSRAM [0x10000]; + uint8_t CIRAM [0x2000]; + uint8_t* RAM; + uint8_t* FillRAM; + uint8_t* SRAM; + uint32_t WRAM_BITS [0x20000 >> 3]; + uint32_t SRAM_BITS [0x10000 >> 3]; + uint32_t IRAM_BITS [0x2000 >> 3]; +} SCheatData; typedef enum { @@ -76,4 +75,3 @@ void S9xOutputCheatSearchResults (SCheatData *cheats); #endif #endif - diff --git a/source/clip.c b/source/clip.c index 8993e72..7931101 100644 --- a/source/clip.c +++ b/source/clip.c @@ -12,10 +12,6 @@ struct Band uint32_t Right; }; -#undef MIN -#undef MAX -#define MIN(A,B) ((A) < (B) ? (A) : (B)) -#define MAX(A,B) ((A) > (B) ? (A) : (B)) #define BAND_EMPTY(B) (B.Left >= B.Right) #define BANDS_INTERSECT(A,B) ((A.Left >= B.Left && A.Left < B.Right) || \ (B.Left >= A.Left && B.Left < A.Right)) @@ -674,4 +670,3 @@ Clip_ok:; } // for (int w... } // for (int c... } - diff --git a/source/cpu.c b/source/cpu.c index 62587de..e702670 100644 --- a/source/cpu.c +++ b/source/cpu.c @@ -14,7 +14,6 @@ #include "spc7110.h" #include "obc1.h" - #include "fxemu.h" extern struct FxInit_s SuperFX; diff --git a/source/cpuaddr.h b/source/cpuaddr.h index 21ce254..6f5e930 100644 --- a/source/cpuaddr.h +++ b/source/cpuaddr.h @@ -285,4 +285,3 @@ static void StackRelativeIndirectIndexed(AccessMode a, InternalOp op) (*op)(Addr); } #endif - diff --git a/source/cpuexec.c b/source/cpuexec.c index 6b1896c..b88e6f1 100644 --- a/source/cpuexec.c +++ b/source/cpuexec.c @@ -13,8 +13,6 @@ #include "sa1.h" #include "spc7110.h" -extern void S9xProcessSound(unsigned int); - void S9xMainLoop_SA1_SFX(void); void S9xMainLoop_SA1_NoSFX(void); void S9xMainLoop_NoSA1_SFX(void); @@ -112,10 +110,7 @@ void S9xMainLoop_SA1_SFX(void) S9xAPUPackStatus(); #endif if (CPU.Flags & SCAN_KEYS_FLAG) - { - S9xSyncSpeed(); CPU.Flags &= ~SCAN_KEYS_FLAG; - } #ifdef DETECT_NASTY_FX_INTERLEAVE if (CPU.BRKTriggered && Settings.SuperFX && !CPU.TriedInterleavedMode2) @@ -196,10 +191,7 @@ void S9xMainLoop_SA1_NoSFX(void) S9xAPUPackStatus(); #endif if (CPU.Flags & SCAN_KEYS_FLAG) - { - S9xSyncSpeed(); CPU.Flags &= ~SCAN_KEYS_FLAG; - } } void S9xMainLoop_NoSA1_SFX(void) @@ -269,10 +261,7 @@ void S9xMainLoop_NoSA1_SFX(void) S9xAPUPackStatus(); #endif if (CPU.Flags & SCAN_KEYS_FLAG) - { - S9xSyncSpeed(); CPU.Flags &= ~SCAN_KEYS_FLAG; - } #ifdef DETECT_NASTY_FX_INTERLEAVE if (CPU.BRKTriggered && Settings.SuperFX && !CPU.TriedInterleavedMode2) @@ -351,10 +340,7 @@ void S9xMainLoop_NoSA1_NoSFX(void) S9xAPUPackStatus(); #endif if (CPU.Flags & SCAN_KEYS_FLAG) - { - S9xSyncSpeed(); CPU.Flags &= ~SCAN_KEYS_FLAG; - } } void S9xSetIRQ(uint32_t source) @@ -402,9 +388,6 @@ void S9xDoHBlankProcessing_SFX() S9xSuperFXExec(); #ifndef USE_BLARGG_APU - if (Settings.SoundSync) - S9xGenerateSound(); - CPU.Cycles -= Settings.H_Max; if (IAPU.APUExecuting) { @@ -436,8 +419,6 @@ void S9xDoHBlankProcessing_SFX() S9xStartHDMA(); } - S9xProcessSound(0); - if (PPU.VTimerEnabled && !PPU.HTimerEnabled && CPU.V_Counter == PPU.IRQVBeamPos) S9xSetIRQ(PPU_V_BEAM_IRQ_SOURCE); @@ -579,9 +560,6 @@ void S9xDoHBlankProcessing_NoSFX() case HBLANK_END_EVENT: #ifndef USE_BLARGG_APU - if (Settings.SoundSync) - S9xGenerateSound(); - CPU.Cycles -= Settings.H_Max; if (IAPU.APUExecuting) { @@ -614,8 +592,6 @@ void S9xDoHBlankProcessing_NoSFX() S9xStartHDMA(); } - S9xProcessSound(0); - if (PPU.VTimerEnabled && !PPU.HTimerEnabled && CPU.V_Counter == PPU.IRQVBeamPos) S9xSetIRQ(PPU_V_BEAM_IRQ_SOURCE); @@ -740,4 +716,3 @@ void S9xDoHBlankProcessing_NoSFX() S9xReschedule(); } - diff --git a/source/cpuexec.h b/source/cpuexec.h index 82de07f..5ecce18 100644 --- a/source/cpuexec.h +++ b/source/cpuexec.h @@ -24,22 +24,21 @@ typedef struct if (CPU.Cycles >= CPU.NextEvent) \ S9xDoHBlankProcessing_NoSFX (); - typedef struct { - uint8_t* Speed; - SOpcodes* S9xOpcodes; + uint8_t* Speed; + SOpcodes* S9xOpcodes; SRegisters Registers; - uint8_t _Carry; - uint8_t _Zero; - uint8_t _Negative; - uint8_t _Overflow; - bool CPUExecuting; - uint32_t ShiftedPB; - uint32_t ShiftedDB; - uint32_t Frame; - uint32_t Scanline; - uint32_t FrameAdvanceCount; + uint8_t _Carry; + uint8_t _Zero; + uint8_t _Negative; + uint8_t _Overflow; + bool CPUExecuting; + uint32_t ShiftedPB; + uint32_t ShiftedDB; + uint32_t Frame; + uint32_t Scanline; + uint32_t FrameAdvanceCount; } SICPU; void S9xMainLoop(void); @@ -132,4 +131,3 @@ static inline void S9xReschedule() } #endif - diff --git a/source/cpumacro.h b/source/cpumacro.h index 5539445..b9195ef 100644 --- a/source/cpumacro.h +++ b/source/cpumacro.h @@ -737,4 +737,3 @@ static void TRB8(long Addr) S9xSetByte(Work8, Addr); } #endif - diff --git a/source/cpuops.c b/source/cpuops.c index c640763..3bf9a36 100644 --- a/source/cpuops.c +++ b/source/cpuops.c @@ -3545,13 +3545,7 @@ static void OpEA(void) #define PushWE(w) \ S9xSetByte ((w)>>8, ICPU.Registers.S.W--);\ - ICPU.Registers.SH=0x01;\ - S9xSetByte ((w)&0xff, (ICPU.Registers.S.W--)&0xFFFF);\ - ICPU.Registers.SH = 0x01; - -#define PushWENew(w) \ - S9xSetByte ((w)>>8, ICPU.Registers.S.W--);\ - S9xSetByte ((w)&0xff, (ICPU.Registers.S.W--)&0xFFFF);\ + S9xSetByte ((w)&0xff, (ICPU.Registers.S.W--)&0xFFFF);\ ICPU.Registers.SH = 0x01; //PEA NL @@ -3561,7 +3555,7 @@ static void OpF4E1(void) #ifndef SA1_OPCODES CPU.Cycles += CPU.MemSpeedx2; #endif - PushWENew((unsigned short)OpAddress); + PushWE((unsigned short)OpAddress); } static void OpF4(void) @@ -3580,7 +3574,7 @@ static void OpD4E1(void) #ifndef SA1_OPCODES CPU.Cycles += CPU.MemSpeed; #endif - PushWENew((unsigned short)OpAddress); + PushWE((unsigned short)OpAddress); } static void OpD4(void) @@ -3599,7 +3593,7 @@ static void Op62E1(void) #ifndef SA1_OPCODES CPU.Cycles += CPU.MemSpeedx2 + ONE_CYCLE; #endif - PushWENew((unsigned short)OpAddress); + PushWE((unsigned short)OpAddress); } static void Op62(void) @@ -3656,7 +3650,7 @@ static void Op8B(void) //PHD NL static void Op0BE1(void) { - PushWENew(ICPU.Registers.D.W); + PushWE(ICPU.Registers.D.W); #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; #endif @@ -3771,14 +3765,6 @@ static void Op5AX0(void) b = S9xGetByte (ICPU.Registers.S.W); #define PullWE(w) \ - ICPU.Registers.S.W++;\ - ICPU.Registers.SH=0x01;\ - w = S9xGetByte (ICPU.Registers.S.W); \ - ICPU.Registers.S.W++; \ - ICPU.Registers.SH=0x01;\ - w |= (S9xGetByte (ICPU.Registers.S.W)<<8); - -#define PullWENew(w) \ PullW(w);\ ICPU.Registers.SH=0x01; @@ -3838,7 +3824,7 @@ static void Op2BE1(void) #ifndef SA1_OPCODES CPU.Cycles += TWO_CYCLES; #endif - PullWENew(ICPU.Registers.D.W); + PullWE(ICPU.Registers.D.W); SetZN16(ICPU.Registers.D.W); } @@ -4443,7 +4429,7 @@ static void Op22E1(void) CPU.Cycles += CPU.MemSpeedx2 + CPU.MemSpeed; #endif PushB(ICPU.Registers.PB); - PushWENew(CPU.PC - CPU.PCBase - 1); + PushWE(CPU.PC - CPU.PCBase - 1); ICPU.Registers.PB = (uint8_t)(OpAddress >> 16); ICPU.ShiftedPB = OpAddress & 0xff0000; S9xSetPCBase(OpAddress); @@ -4464,7 +4450,7 @@ static void Op22(void) static void Op6BE1(void) { - PullWENew(ICPU.Registers.PC); + PullWE(ICPU.Registers.PC); PullB(ICPU.Registers.PB); ICPU.ShiftedPB = ICPU.Registers.PB << 16; S9xSetPCBase(ICPU.ShiftedPB + ((ICPU.Registers.PC + 1) & 0xffff)); @@ -4503,7 +4489,7 @@ static void OpFCE1(void) #ifndef SA1_OPCODES CPU.Cycles += CPU.MemSpeedx2 + ONE_CYCLE; #endif - PushWENew(CPU.PC - CPU.PCBase - 1); + PushWE(CPU.PC - CPU.PCBase - 1); S9xSetPCBase(ICPU.ShiftedPB + OpAddress); } @@ -5224,4 +5210,3 @@ SOpcodes S9xOpcodesM0X1[256] = {OpFAX1}, {OpFB}, {OpFC}, {OpFDM0}, {OpFEM0}, {OpFFM0} }; - diff --git a/source/cpuops.h b/source/cpuops.h index 7ed310a..1fcaec9 100644 --- a/source/cpuops.h +++ b/source/cpuops.h @@ -10,4 +10,3 @@ if (CPU.IRQActive && !CheckFlag (IRQ) && !Settings.DisableIRQ) \ S9xOpcode_IRQ() #endif - diff --git a/source/data.c b/source/data.c index e039040..86f1723 100644 --- a/source/data.c +++ b/source/data.c @@ -85,5 +85,3 @@ uint8_t mul_brightness [16][32] = 0x1e, 0x1f } }; - - diff --git a/source/display.h b/source/display.h index 8b6e934..d43d4ff 100644 --- a/source/display.h +++ b/source/display.h @@ -18,4 +18,3 @@ bool S9xLoadROMImage(const char* string); const char* S9xGetFilename(const char* extension); #endif - diff --git a/source/dma.c b/source/dma.c index c0956c4..fc1356b 100644 --- a/source/dma.c +++ b/source/dma.c @@ -12,7 +12,6 @@ #include "missing.h" #include "dma.h" #include "apu.h" -#include "gfx.h" #include "sa1.h" #include "spc7110.h" diff --git a/source/dma.h b/source/dma.h index 5d4f358..c93ce64 100644 --- a/source/dma.h +++ b/source/dma.h @@ -9,4 +9,3 @@ void S9xStartHDMA(); void S9xDoDMA(uint8_t); #endif - diff --git a/source/dsp1.c b/source/dsp1.c index cccae23..a5b5e79 100644 --- a/source/dsp1.c +++ b/source/dsp1.c @@ -1125,15 +1125,15 @@ uint8_t DSP3GetByte(uint16_t address) typedef struct { - bool waiting4command; - bool half_command; + bool waiting4command; + bool half_command; uint16_t command; uint32_t in_count; uint32_t in_index; uint32_t out_count; uint32_t out_index; - uint8_t parameters [512]; - uint8_t output [512]; + uint8_t parameters [512]; + uint8_t output [512]; } SDSP4; SDSP4 DSP4; @@ -1412,4 +1412,3 @@ uint8_t DSP4GetByte(uint16_t address) return t; } - diff --git a/source/dsp1.h b/source/dsp1.h index 0c18155..7cd97c6 100644 --- a/source/dsp1.h +++ b/source/dsp1.h @@ -20,16 +20,16 @@ uint8_t DSP4GetByte(uint16_t address); typedef struct { - bool waiting4command; - bool first_parameter; - uint8_t command; + bool waiting4command; + bool first_parameter; + uint8_t command; uint32_t in_count; uint32_t in_index; uint32_t out_count; uint32_t out_index; - uint8_t parameters [512]; + uint8_t parameters [512]; //output was 512 for DSP-2 work, updated to reflect current thinking on DSP-3 - uint8_t output [512]; + uint8_t output [512]; } SDSP1; void S9xResetDSP1(); @@ -38,4 +38,3 @@ void S9xSetDSP(uint8_t Byte, uint16_t Address); extern SDSP1 DSP1; #endif - diff --git a/source/fxdbg.c b/source/fxdbg.c deleted file mode 100644 index 1988cff..0000000 --- a/source/fxdbg.c +++ /dev/null @@ -1,322 +0,0 @@ -#include "../copyright" - -#include "fxemu.h" -#include "fxinst.h" -#include <stdio.h> -#include <string.h> - -extern const char* fx_apvMnemonicTable[]; -extern struct FxRegs_s GSU; - - -/* - When printing a line from the pipe, it could look like this: - - 01:8006 f4 fb 86 iwt r4,#$86fb - - The values are: - program bank: 01 - adress: 8006 - values at memory address 8006: f4 fb 86 - instruction in the pipe: iwt r4,#$86fb - - Note! If the instruction has more than one byte (like in 'iwt') - and the instruction is in a delay slot, the second and third - byte displayed will not be the same as those used. - Since the instrction is in a delay slot, the first byte - of the instruction will be taken from the pipe at the address - after the branch instruction, and the next one or two bytes - will be taken from the address that the branch points to. - This is a bit complicated, but I've taken this into account, - in this debug function. (See the diffrence of how the values - vPipe1 and vPipe2 are read, compared to the values vByte1 and - vByte2) - - */ -void FxPipeString(char* pvString) -{ - char* p; - uint32_t vOpcode = (GSU.vStatusReg & 0x300) | ((uint32_t)PIPE); - const char* m = fx_apvMnemonicTable[vOpcode]; - uint8_t vPipe1, vPipe2, vByte1, vByte2; - uint8_t vPipeBank = GSU.vPipeAdr >> 16; - - /* The next two bytes after the pipe's address */ - vPipe1 = GSU.apvRomBank[vPipeBank][USEX16(GSU.vPipeAdr + 1)]; - vPipe2 = GSU.apvRomBank[vPipeBank][USEX16(GSU.vPipeAdr + 2)]; - - /* The actual next two bytes to be read */ - vByte1 = PRGBANK(USEX16(R15)); - vByte2 = PRGBANK(USEX16(R15 + 1)); - - /* Print ROM address of the pipe */ - sprintf(pvString, "%02x:%04x %02x ", - USEX8(vPipeBank), USEX16(GSU.vPipeAdr), USEX8(PIPE)); - p = &pvString[strlen(pvString)]; - - /* Check if it's a branch instruction */ - if (PIPE >= 0x05 && PIPE <= 0x0f) - { - sprintf(&pvString[11], "%02x ", USEX8(vPipe1)); -#ifdef BRANCH_DELAY_RELATIVE - sprintf(p, m, USEX16(R15 + SEX8(vByte1) + 1)); -#else - sprintf(p, m, USEX16(R15 + SEX8(vByte1) - 1)); -#endif - } - /* Check for 'move' instruction */ - else if (PIPE >= 0x10 && PIPE <= 0x1f && TF(B)) - sprintf(p, "move r%d,r%d", USEX8(PIPE & 0x0f), GSU.pvSreg - GSU.avReg); - /* Check for 'ibt', 'lms' or 'sms' */ - else if (PIPE >= 0xa0 && PIPE <= 0xaf) - { - sprintf(&pvString[11], "%02x ", USEX8(vPipe1)); - if ((GSU.vStatusReg & 0x300) == 0x100 || (GSU.vStatusReg & 0x300) == 0x200) - sprintf(p, m, USEX16(vByte1) << 1); - else - sprintf(p, m, USEX16(vByte1)); - } - /* Check for 'moves' */ - else if (PIPE >= 0xb0 && PIPE <= 0xbf && TF(B)) - sprintf(p, "moves r%d,r%d", GSU.pvDreg - GSU.avReg, USEX8(PIPE & 0x0f)); - /* Check for 'iwt', 'lm' or 'sm' */ - else if (PIPE >= 0xf0) - { - sprintf(&pvString[11], "%02x %02x ", USEX8(vPipe1), USEX8(vPipe2)); - sprintf(p, m, USEX8(vByte1) | (USEX16(vByte2) << 8)); - } - /* Normal instruction */ - else - strcpy(p, m); -} - -const char* fx_apvMnemonicTable[] = -{ - /* - * ALT0 Table - */ - /* 00 - 0f */ - "stop", "nop", "cache", "lsr", "rol", "bra $%04x", "blt $%04x", "bge $%04x", - "bne $%04x", "beq $%04x", "bpl $%04x", "bmi $%04x", "bcc $%04x", "bcs $%04x", "bvc $%04x", "bvs $%04x", - /* 10 - 1f */ - "to r0", "to r1", "to r2", "to r3", "to r4", "to r5", "to r6", "to r7", - "to r8", "to r9", "to r10", "to r11", "to r12", "to r13", "to r14", "to r15", - /* 20 - 2f */ - "with r0", "with r1", "with r2", "with r3", "with r4", "with r5", "with r6", "with r7", - "with r8", "with r9", "with r10", "with r11", "with r12", "with r13", "with r14", "with r15", - /* 30 - 3f */ - "stw (r0)", "stw (r1)", "stw (r2)", "stw (r3)", "stw (r4)", "stw (r5)", "stw (r6)", "stw (r7)", - "stw (r8)", "stw (r9)", "stw (r10)", "stw (r11)", "loop", "alt1", "alt2", "alt3", - /* 40 - 4f */ - "ldw (r0)", "ldw (r1)", "ldw (r2)", "ldw (r3)", "ldw (r4)", "ldw (r5)", "ldw (r6)", "ldw (r7)", - "ldw (r8)", "ldw (r9)", "ldw (r10)", "ldw (r11)", "plot", "swap", "color", "not", - /* 50 - 5f */ - "add r0", "add r1", "add r2", "add r3", "add r4", "add r5", "add r6", "add r7", - "add r8", "add r9", "add r10", "add r11", "add r12", "add r13", "add r14", "add r15", - /* 60 - 6f */ - "sub r0", "sub r1", "sub r2", "sub r3", "sub r4", "sub r5", "sub r6", "sub r7", - "sub r8", "sub r9", "sub r10", "sub r11", "sub r12", "sub r13", "sub r14", "sub r15", - /* 70 - 7f */ - "merge", "and r1", "and r2", "and r3", "and r4", "and r5", "and r6", "and r7", - "and r8", "and r9", "and r10", "and r11", "and r12", "and r13", "and r14", "and r15", - /* 80 - 8f */ - "mult r0", "mult r1", "mult r2", "mult r3", "mult r4", "mult r5", "mult r6", "mult r7", - "mult r8", "mult r9", "mult r10", "mult r11", "mult r12", "mult r13", "mult r14", "mult r15", - /* 90 - 9f */ - "sbk", "link #1", "link #2", "link #3", "link #4", "sex", "asr", "ror", - "jmp (r8)", "jmp (r9)", "jmp (r10)", "jmp (r11)", "jmp (r12)", "jmp (r13)", "lob", "fmult", - /* a0 - af */ - "ibt r0,#$%02x", "ibt r1,#$%02x", "ibt r2,#$%02x", "ibt r3,#$%02x", - "ibt r4,#$%02x", "ibt r5,#$%02x", "ibt r6,#$%02x", "ibt r7,#$%02x", - "ibt r8,#$%02x", "ibt r9,#$%02x", "ibt r10,#$%02x", "ibt r11,#$%02x", - "ibt r12,#$%02x", "ibt r13,#$%02x", "ibt r14,#$%02x", "ibt r15,#$%02x", - /* b0 - bf */ - "from r0", "from r1", "from r2", "from r3", "from r4", "from r5", "from r6", "from r7", - "from r8", "from r9", "from r10", "from r11", "from r12", "from r13", "from r14", "from r15", - /* c0 - cf */ - "hib", "or r1", "or r2", "or r3", "or r4", "or r5", "or r6", "or r7", - "or r8", "or r9", "or r10", "or r11", "or r12", "or r13", "or r14", "or r15", - /* d0 - df */ - "inc r0", "inc r1", "inc r2", "inc r3", "inc r4", "inc r5", "inc r6", "inc r7", - "inc r8", "inc r9", "inc r10", "inc r11", "inc r12", "inc r13", "inc r14", "getc", - /* e0 - ef */ - "dec r0", "dec r1", "dec r2", "dec r3", "dec r4", "dec r5", "dec r6", "dec r7", - "dec r8", "dec r9", "dec r10", "dec r11", "dec r12", "dec r13", "dec r14", "getb", - /* f0 - ff */ - "iwt r0,#$%04x", "iwt r1,#$%04x", "iwt r2,#$%04x", "iwt r3,#$%04x", - "iwt r4,#$%04x", "iwt r5,#$%04x", "iwt r6,#$%04x", "iwt r7,#$%04x", - "iwt r8,#$%04x", "iwt r9,#$%04x", "iwt r10,#$%04x", "iwt r11,#$%04x", - "iwt r12,#$%04x", "iwt r13,#$%04x", "iwt r14,#$%04x", "iwt r15,#$%04x", - - /* - * ALT1 Table - */ - - /* 00 - 0f */ - "stop", "nop", "cache", "lsr", "rol", "bra $%04x", "blt $%04x", "bge $%04x", - "bne $%04x", "beq $%04x", "bpl $%04x", "bmi $%04x", "bcc $%04x", "bcs $%04x", "bvc $%04x", "bvs $%04x", - /* 10 - 1f */ - "to r0", "to r1", "to r2", "to r3", "to r4", "to r5", "to r6", "to r7", - "to r8", "to r9", "to r10", "to r11", "to r12", "to r13", "to r14", "to r15", - /* 20 - 2f */ - "with r0", "with r1", "with r2", "with r3", "with r4", "with r5", "with r6", "with r7", - "with r8", "with r9", "with r10", "with r11", "with r12", "with r13", "with r14", "with r15", - /* 30 - 3f */ - "stb (r0)", "stb (r1)", "stb (r2)", "stb (r3)", "stb (r4)", "stb (r5)", "stb (r6)", "stb (r7)", - "stb (r8)", "stb (r9)", "stb (r10)", "stb (r11)", "loop", "alt1", "alt2", "alt3", - /* 40 - 4f */ - "ldb (r0)", "ldb (r1)", "ldb (r2)", "ldb (r3)", "ldb (r4)", "ldb (r5)", "ldb (r6)", "ldb (r7)", - "ldb (r8)", "ldb (r9)", "ldb (r10)", "ldb (r11)", "rpix", "swap", "cmode", "not", - /* 50 - 5f */ - "adc r0", "adc r1", "adc r2", "adc r3", "adc r4", "adc r5", "adc r6", "adc r7", - "adc r8", "adc r9", "adc r10", "adc r11", "adc r12", "adc r13", "adc r14", "adc r15", - /* 60 - 6f */ - "sbc r0", "sbc r1", "sbc r2", "sbc r3", "sbc r4", "sbc r5", "sbc r6", "sbc r7", - "sbc r8", "sbc r9", "sbc r10", "sbc r11", "sbc r12", "sbc r13", "sbc r14", "sbc r15", - /* 70 - 7f */ - "merge", "bic r1", "bic r2", "bic r3", "bic r4", "bic r5", "bic r6", "bic r7", - "bic r8", "bic r9", "bic r10", "bic r11", "bic r12", "bic r13", "bic r14", "bic r15", - /* 80 - 8f */ - "umult r0", "umult r1", "umult r2", "umult r3", "umult r4", "umult r5", "umult r6", "umult r7", - "umult r8", "umult r9", "umult r10", "umult r11", "umult r12", "umult r13", "umult r14", "umult r15", - /* 90 - 9f */ - "sbk", "link #1", "link #2", "link #3", "link #4", "sex", "div2", "ror", - "ljmp (r8)", "ljmp (r9)", "ljmp (r10)", "ljmp (r11)", "ljmp (r12)", "ljmp (r13)", "lob", "lmult", - /* a0 - af */ - "lms r0,($%04x)", "lms r1,($%04x)", "lms r2,($%04x)", "lms r3,($%04x)", - "lms r4,($%04x)", "lms r5,($%04x)", "lms r6,($%04x)", "lms r7,($%04x)", - "lms r8,($%04x)", "lms r9,($%04x)", "lms r10,($%04x)", "lms r11,($%04x)", - "lms r12,($%04x)", "lms r13,($%04x)", "lms r14,($%04x)", "lms r15,($%04x)", - /* b0 - bf */ - "from r0", "from r1", "from r2", "from r3", "from r4", "from r5", "from r6", "from r7", - "from r8", "from r9", "from r10", "from r11", "from r12", "from r13", "from r14", "from r15", - /* c0 - cf */ - "hib", "xor r1", "xor r2", "xor r3", "xor r4", "xor r5", "xor r6", "xor r7", - "xor r8", "xor r9", "xor r10", "xor r11", "xor r12", "xor r13", "xor r14", "xor r15", - /* d0 - df */ - "inc r0", "inc r1", "inc r2", "inc r3", "inc r4", "inc r5", "inc r6", "inc r7", - "inc r8", "inc r9", "inc r10", "inc r11", "inc r12", "inc r13", "inc r14", "getc", - /* e0 - ef */ - "dec r0", "dec r1", "dec r2", "dec r3", "dec r4", "dec r5", "dec r6", "dec r7", - "dec r8", "dec r9", "dec r10", "dec r11", "dec r12", "dec r13", "dec r14", "getbh", - /* f0 - ff */ - "lm r0,($%04x)", "lm r1,($%04x)", "lm r2,($%04x)", "lm r3,($%04x)", - "lm r4,($%04x)", "lm r5,($%04x)", "lm r6,($%04x)", "lm r7,($%04x)", - "lm r8,($%04x)", "lm r9,($%04x)", "lm r10,($%04x)", "lm r11,($%04x)", - "lm r12,($%04x)", "lm r13,($%04x)", "lm r14,($%04x)", "lm r15,($%04x)", - - /* - * ALT2 Table - */ - - /* 00 - 0f */ - "stop", "nop", "cache", "lsr", "rol", "bra $%04x", "blt $%04x", "bge $%04x", - "bne $%04x", "beq $%04x", "bpl $%04x", "bmi $%04x", "bcc $%04x", "bcs $%04x", "bvc $%04x", "bvs $%04x", - /* 10 - 1f */ - "to r0", "to r1", "to r2", "to r3", "to r4", "to r5", "to r6", "to r7", - "to r8", "to r9", "to r10", "to r11", "to r12", "to r13", "to r14", "to r15", - /* 20 - 2f */ - "with r0", "with r1", "with r2", "with r3", "with r4", "with r5", "with r6", "with r7", - "with r8", "with r9", "with r10", "with r11", "with r12", "with r13", "with r14", "with r15", - /* 30 - 3f */ - "stw (r0)", "stw (r1)", "stw (r2)", "stw (r3)", "stw (r4)", "stw (r5)", "stw (r6)", "stw (r7)", - "stw (r8)", "stw (r9)", "stw (r10)", "stw (r11)", "loop", "alt1", "alt2", "alt3", - /* 40 - 4f */ - "ldw (r0)", "ldw (r1)", "ldw (r2)", "ldw (r3)", "ldw (r4)", "ldw (r5)", "ldw (r6)", "ldw (r7)", - "ldw (r8)", "ldw (r9)", "ldw (r10)", "ldw (r11)", "plot", "swap", "color", "not", - /* 50 - 5f */ - "add #0", "add #1", "add #2", "add #3", "add #4", "add #5", "add #6", "add #7", - "add #8", "add #9", "add #10", "add #11", "add #12", "add #13", "add #14", "add #15", - /* 60 - 6f */ - "sub #0", "sub #1", "sub #2", "sub #3", "sub #4", "sub #5", "sub #6", "sub #7", - "sub #8", "sub #9", "sub #10", "sub #11", "sub #12", "sub #13", "sub #14", "sub #15", - /* 70 - 7f */ - "merge", "and #1", "and #2", "and #3", "and #4", "and #5", "and #6", "and #7", - "and #8", "and #9", "and #10", "and #11", "and #12", "and #13", "and #14", "and #15", - /* 80 - 8f */ - "mult #0", "mult #1", "mult #2", "mult #3", "mult #4", "mult #5", "mult #6", "mult #7", - "mult #8", "mult #9", "mult #10", "mult #11", "mult #12", "mult #13", "mult #14", "mult #15", - /* 90 - 9f */ - "sbk", "link #1", "link #2", "link #3", "link #4", "sex", "asr", "ror", - "jmp (r8)", "jmp (r9)", "jmp (r10)", "jmp (r11)", "jmp (r12)", "jmp (r13)", "lob", "fmult", - /* a0 - af */ - "sms ($%04x),r0", "sms ($%04x),r1", "sms ($%04x),r2", "sms ($%04x),r3", - "sms ($%04x),r4", "sms ($%04x),r5", "sms ($%04x),r6", "sms ($%04x),r7", - "sms ($%04x),r8", "sms ($%04x),r9", "sms ($%04x),r10", "sms ($%04x),r11", - "sms ($%04x),r12", "sms ($%04x),r13", "sms ($%04x),r14", "sms ($%04x),r15", - /* b0 - bf */ - "from r0", "from r1", "from r2", "from r3", "from r4", "from r5", "from r6", "from r7", - "from r8", "from r9", "from r10", "from r11", "from r12", "from r13", "from r14", "from r15", - /* c0 - cf */ - "hib", "or #1", "or #2", "or #3", "or #4", "or #5", "or #6", "or #7", - "or #8", "or #9", "or #10", "or #11", "or #12", "or #13", "or #14", "or #15", - /* d0 - df */ - "inc r0", "inc r1", "inc r2", "inc r3", "inc r4", "inc r5", "inc r6", "inc r7", - "inc r8", "inc r9", "inc r10", "inc r11", "inc r12", "inc r13", "inc r14", "ramb", - /* e0 - ef */ - "dec r0", "dec r1", "dec r2", "dec r3", "dec r4", "dec r5", "dec r6", "dec r7", - "dec r8", "dec r9", "dec r10", "dec r11", "dec r12", "dec r13", "dec r14", "getbl", - /* f0 - ff */ - "sm ($%04x),r0", "sm ($%04x),r1", "sm ($%04x),r2", "sm ($%04x),r3", - "sm ($%04x),r4", "sm ($%04x),r5", "sm ($%04x),r6", "sm ($%04x),r7", - "sm ($%04x),r8", "sm ($%04x),r9", "sm ($%04x),r10", "sm ($%04x),r11", - "sm ($%04x),r12", "sm ($%04x),r13", "sm ($%04x),r14", "sm ($%04x),r15", - - /* - * ALT3 Table - */ - - /* 00 - 0f */ - "stop", "nop", "cache", "lsr", "rol", "bra $%04x", "blt $%04x", "bge $%04x", - "bne $%04x", "beq $%04x", "bpl $%04x", "bmi $%04x", "bcc $%04x", "bcs $%04x", "bvc $%04x", "bvs $%04x", - /* 10 - 1f */ - "to r0", "to r1", "to r2", "to r3", "to r4", "to r5", "to r6", "to r7", - "to r8", "to r9", "to r10", "to r11", "to r12", "to r13", "to r14", "to r15", - /* 20 - 2f */ - "with r0", "with r1", "with r2", "with r3", "with r4", "with r5", "with r6", "with r7", - "with r8", "with r9", "with r10", "with r11", "with r12", "with r13", "with r14", "with r15", - /* 30 - 3f */ - "stb (r0)", "stb (r1)", "stb (r2)", "stb (r3)", "stb (r4)", "stb (r5)", "stb (r6)", "stb (r7)", - "stb (r8)", "stb (r9)", "stb (r10)", "stb (r11)", "loop", "alt1", "alt2", "alt3", - /* 40 - 4f */ - "ldb (r0)", "ldb (r1)", "ldb (r2)", "ldb (r3)", "ldb (r4)", "ldb (r5)", "ldb (r6)", "ldb (r7)", - "ldb (r8)", "ldb (r9)", "ldb (r10)", "ldb (r11)", "rpix", "swap", "cmode", "not", - /* 50 - 5f */ - "adc #0", "adc #1", "adc #2", "adc #3", "adc #4", "adc #5", "adc #6", "adc #7", - "adc #8", "adc #9", "adc #10", "adc #11", "adc #12", "adc #13", "adc #14", "adc #15", - /* 60 - 6f */ - "cmp r0", "cmp r1", "cmp r2", "cmp r3", "cmp r4", "cmp r5", "cmp r6", "cmp r7", - "cmp r8", "cmp r9", "cmp r10", "cmp r11", "cmp r12", "cmp r13", "cmp r14", "cmp r15", - /* 70 - 7f */ - "merge", "bic #1", "bic #2", "bic #3", "bic #4", "bic #5", "bic #6", "bic #7", - "bic #8", "bic #9", "bic #10", "bic #11", "bic #12", "bic #13", "bic #14", "bic #15", - /* 80 - 8f */ - "umult #0", "umult #1", "umult #2", "umult #3", "umult #4", "umult #5", "umult #6", "umult #7", - "umult #8", "umult #9", "umult #10", "umult #11", "umult #12", "umult #13", "umult #14", "umult #15", - /* 90 - 9f */ - "sbk", "link #1", "link #2", "link #3", "link #4", "sex", "div2", "ror", - "ljmp (r8)", "ljmp (r9)", "ljmp (r10)", "ljmp (r11)", "ljmp (r12)", "ljmp (r13)", "lob", "lmult", - /* a0 - af */ - "lms r0,($%04x)", "lms r1,($%04x)", "lms r2,($%04x)", "lms r3,($%04x)", - "lms r4,($%04x)", "lms r5,($%04x)", "lms r6,($%04x)", "lms r7,($%04x)", - "lms r8,($%04x)", "lms r9,($%04x)", "lms r10,($%04x)", "lms r11,($%04x)", - "lms r12,($%04x)", "lms r13,($%04x)", "lms r14,($%04x)", "lms r15,($%04x)", - /* b0 - bf */ - "from r0", "from r1", "from r2", "from r3", "from r4", "from r5", "from r6", "from r7", - "from r8", "from r9", "from r10", "from r11", "from r12", "from r13", "from r14", "from r15", - /* c0 - cf */ - "hib", "xor #1", "xor #2", "xor #3", "xor #4", "xor #5", "xor #6", "xor #7", - "xor #8", "xor #9", "xor #10", "xor #11", "xor #12", "xor #13", "xor #14", "xor #15", - /* d0 - df */ - "inc r0", "inc r1", "inc r2", "inc r3", "inc r4", "inc r5", "inc r6", "inc r7", - "inc r8", "inc r9", "inc r10", "inc r11", "inc r12", "inc r13", "inc r14", "romb", - /* e0 - ef */ - "dec r0", "dec r1", "dec r2", "dec r3", "dec r4", "dec r5", "dec r6", "dec r7", - "dec r8", "dec r9", "dec r10", "dec r11", "dec r12", "dec r13", "dec r14", "getbs", - /* f0 - ff */ - "lm r0,($%04x)", "lm r1,($%04x)", "lm r2,($%04x)", "lm r3,($%04x)", - "lm r4,($%04x)", "lm r5,($%04x)", "lm r6,($%04x)", "lm r7,($%04x)", - "lm r8,($%04x)", "lm r9,($%04x)", "lm r10,($%04x)", "lm r11,($%04x)", - "lm r12,($%04x)", "lm r13,($%04x)", "lm r14,($%04x)", "lm r15,($%04x)", -}; - diff --git a/source/fxemu.c b/source/fxemu.c index c16ee58..c789e23 100644 --- a/source/fxemu.c +++ b/source/fxemu.c @@ -7,7 +7,7 @@ #include <stdio.h> /* The FxChip Emulator's internal variables */ -struct FxRegs_s GSU = FxRegs_s_null; +struct FxRegs_s GSU; // This will be initialized when loading a ROM uint32_t(**fx_ppfFunctionTable)(uint32_t) = 0; void (**fx_ppfPlotTable)() = 0; @@ -477,4 +477,3 @@ uint8_t FxPipe() { return GSU.vPipe; } - diff --git a/source/fxemu.h b/source/fxemu.h index 5b1efac..6c717e3 100644 --- a/source/fxemu.h +++ b/source/fxemu.h @@ -9,11 +9,11 @@ struct FxInit_s { uint32_t vFlags; - uint8_t* pvRegisters; /* 768 bytes located in the memory at address 0x3000 */ - uint32_t nRamBanks; /* Number of 64kb-banks in GSU-RAM/BackupRAM (banks 0x70-0x73) */ - uint8_t* pvRam; /* Pointer to GSU-RAM */ - uint32_t nRomBanks; /* Number of 32kb-banks in Cart-ROM */ - uint8_t* pvRom; /* Pointer to Cart-ROM */ + uint8_t* pvRegisters; /* 768 bytes located in the memory at address 0x3000 */ + uint32_t nRamBanks; /* Number of 64kb-banks in GSU-RAM/BackupRAM (banks 0x70-0x73) */ + uint8_t* pvRam; /* Pointer to GSU-RAM */ + uint32_t nRomBanks; /* Number of 32kb-banks in Cart-ROM */ + uint8_t* pvRom; /* Pointer to Cart-ROM */ }; /* Reset the FxChip */ @@ -39,9 +39,6 @@ extern uint32_t FxGetPlotOptionRegister(); extern uint32_t FxGetSourceRegisterIndex(); extern uint32_t FxGetDestinationRegisterIndex(); -/* Get string for opcode currently in the pipe */ -extern void FxPipeString(char* pvString); - /* Get the byte currently in the pipe */ extern uint8_t FxPipe(); @@ -65,4 +62,3 @@ extern void fx_updateRamBank(uint8_t Byte); extern void fx_computeScreenPointers(); #endif - diff --git a/source/fxinst.h b/source/fxinst.h index 4e66a54..7cb0d2e 100644 --- a/source/fxinst.h +++ b/source/fxinst.h @@ -124,87 +124,73 @@ /* Number of banks in GSU RAM */ #define FX_RAM_BANKS 4 -/* Emulate proper R14 ROM access (slower, but safer) */ -/* #define FX_DO_ROMBUFFER */ - -/* Address checking (definately slow) */ -/* #define FX_ADDRESS_CHECK */ - struct FxRegs_s { /* FxChip registers */ - uint32_t avReg[16]; /* 16 Generic registers */ - uint32_t vColorReg; /* Internal color register */ - uint32_t vPlotOptionReg; /* Plot option register */ - uint32_t vStatusReg; /* Status register */ - uint32_t vPrgBankReg; /* Program bank index register */ - uint32_t vRomBankReg; /* Rom bank index register */ - uint32_t vRamBankReg; /* Ram bank index register */ - uint32_t vCacheBaseReg; /* Cache base address register */ - uint32_t vCacheFlags; /* Saying what parts of the cache was written to */ - uint32_t vLastRamAdr; /* Last RAM address accessed */ - uint32_t* pvDreg; /* Pointer to current destination register */ - uint32_t* pvSreg; /* Pointer to current source register */ - uint8_t vRomBuffer; /* Current byte read by R14 */ - uint8_t vPipe; /* Instructionset pipe */ - uint32_t vPipeAdr; /* The address of where the pipe was read from */ + uint32_t avReg[16]; /* 16 Generic registers */ + uint32_t vColorReg; /* Internal color register */ + uint32_t vPlotOptionReg; /* Plot option register */ + uint32_t vStatusReg; /* Status register */ + uint32_t vPrgBankReg; /* Program bank index register */ + uint32_t vRomBankReg; /* Rom bank index register */ + uint32_t vRamBankReg; /* Ram bank index register */ + uint32_t vCacheBaseReg; /* Cache base address register */ + uint32_t vCacheFlags; /* Saying what parts of the cache was written to */ + uint32_t vLastRamAdr; /* Last RAM address accessed */ + uint32_t* pvDreg; /* Pointer to current destination register */ + uint32_t* pvSreg; /* Pointer to current source register */ + uint8_t vRomBuffer; /* Current byte read by R14 */ + uint8_t vPipe; /* Instructionset pipe */ + uint32_t vPipeAdr; /* The address of where the pipe was read from */ /* status register optimization stuff */ - uint32_t vSign; /* v & 0x8000 */ - uint32_t vZero; /* v == 0 */ - uint32_t vCarry; /* a value of 1 or 0 */ - int32_t vOverflow; /* (v >= 0x8000 || v < -0x8000) */ + uint32_t vSign; /* v & 0x8000 */ + uint32_t vZero; /* v == 0 */ + uint32_t vCarry; /* a value of 1 or 0 */ + int32_t vOverflow; /* (v >= 0x8000 || v < -0x8000) */ /* Other emulator variables */ - int32_t vErrorCode; - uint32_t vIllegalAddress; - - uint8_t bBreakPoint; - uint32_t vBreakPoint; - uint32_t vStepPoint; - - uint8_t* pvRegisters; /* 768 bytes located in the memory at address 0x3000 */ - uint32_t nRamBanks; /* Number of 64kb-banks in FxRam (Don't confuse it with SNES-Ram!!!) */ - uint8_t* pvRam; /* Pointer to FxRam */ - uint32_t nRomBanks; /* Number of 32kb-banks in Cart-ROM */ - uint8_t* pvRom; /* Pointer to Cart-ROM */ - - uint32_t vMode; /* Color depth/mode */ - uint32_t vPrevMode; /* Previous depth */ - uint8_t* pvScreenBase; - uint8_t* apvScreen[32]; /* Pointer to each of the 32 screen colums */ - int x[32]; - uint32_t vScreenHeight; /* 128, 160, 192 or 256 (could be overriden by cmode) */ - uint32_t vScreenRealHeight; /* 128, 160, 192 or 256 */ - uint32_t vPrevScreenHeight; - uint32_t vScreenSize; - void (*pfPlot)(); - void (*pfRpix)(); - - uint8_t* pvRamBank; /* Pointer to current RAM-bank */ - uint8_t* pvRomBank; /* Pointer to current ROM-bank */ - uint8_t* pvPrgBank; /* Pointer to current program ROM-bank */ - - uint8_t* apvRamBank[FX_RAM_BANKS];/* Ram bank table (max 256kb) */ - uint8_t* apvRomBank[256]; /* Rom bank table */ - - uint8_t bCacheActive; - uint8_t* pvCache; /* Pointer to the GSU cache */ - uint8_t avCacheBackup[512]; /* Backup of ROM when the cache has replaced it */ - uint32_t vCounter; - uint32_t vInstCount; - uint32_t vSCBRDirty; /* if SCBR is written, our cached screen pointers need updating */ + int32_t vErrorCode; + uint32_t vIllegalAddress; + + uint8_t bBreakPoint; + uint32_t vBreakPoint; + uint32_t vStepPoint; + + uint8_t* pvRegisters; /* 768 bytes located in the memory at address 0x3000 */ + uint32_t nRamBanks; /* Number of 64kb-banks in FxRam (Don't confuse it with SNES-Ram!!!) */ + uint8_t* pvRam; /* Pointer to FxRam */ + uint32_t nRomBanks; /* Number of 32kb-banks in Cart-ROM */ + uint8_t* pvRom; /* Pointer to Cart-ROM */ + + uint32_t vMode; /* Color depth/mode */ + uint32_t vPrevMode; /* Previous depth */ + uint8_t* pvScreenBase; + uint8_t* apvScreen[32]; /* Pointer to each of the 32 screen colums */ + int x[32]; + uint32_t vScreenHeight; /* 128, 160, 192 or 256 (could be overriden by cmode) */ + uint32_t vScreenRealHeight; /* 128, 160, 192 or 256 */ + uint32_t vPrevScreenHeight; + uint32_t vScreenSize; + void (*pfPlot)(); + void (*pfRpix)(); + + uint8_t* pvRamBank; /* Pointer to current RAM-bank */ + uint8_t* pvRomBank; /* Pointer to current ROM-bank */ + uint8_t* pvPrgBank; /* Pointer to current program ROM-bank */ + + uint8_t* apvRamBank[FX_RAM_BANKS]; /* Ram bank table (max 256kb) */ + uint8_t* apvRomBank[256]; /* Rom bank table */ + + uint8_t bCacheActive; + uint8_t* pvCache; /* Pointer to the GSU cache */ + uint8_t avCacheBackup[512]; /* Backup of ROM when the cache has replaced it */ + uint32_t vCounter; + uint32_t vInstCount; + uint32_t vSCBRDirty; /* if SCBR is written, our cached screen pointers need updating */ }; -#define FxRegs_s_null { \ - {0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ - NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, \ - 0, 0, 0, 0, NULL, 0, NULL, 0, NULL, 0, \ - 0, NULL, {NULL}, {0}, 0, 0, 0, 0, NULL, NULL, \ - NULL, NULL, NULL, {NULL}, {NULL}, 0, NULL, {0}, 0, 0, \ -} - /* GSU registers */ #define GSU_R0 0x000 #define GSU_R1 0x002 @@ -292,11 +278,7 @@ struct FxRegs_s #define PRGBANK(idx) GSU.pvPrgBank[USEX16(idx)] /* Update pipe from ROM */ -#if 0 -#define FETCHPIPE { PIPE = PRGBANK(R15); GSU.vPipeAdr = (GSU.vPrgBankReg<<16) + R15; } -#else #define FETCHPIPE { PIPE = PRGBANK(R15); } -#endif /* ABS */ #define ABS(x) ((x)<0?-(x):(x)) @@ -386,4 +368,3 @@ extern void (*fx_ar_apfPlotTable[])(); #define BRANCH_DELAY_RELATIVE #endif - diff --git a/source/getset.h b/source/getset.h index 8939e76..ebd377a 100644 --- a/source/getset.h +++ b/source/getset.h @@ -478,11 +478,9 @@ INLINE uint8_t* GetBasePointer(uint32_t Address) } case MAP_SPC7110_ROM: return Get7110BasePtr(Address); - case MAP_PPU: - //just a guess, but it looks like this should match the CPU as a source. - return (Memory.FillRAM); - case MAP_CPU: - //fixes Ogre Battle's green lines + case MAP_PPU: //just a guess, but it looks like this should match the CPU as a source. + case MAP_CPU: //fixes Ogre Battle's green lines + case MAP_OBC_RAM: return (Memory.FillRAM); case MAP_DSP: return (Memory.FillRAM - 0x6000); @@ -495,8 +493,6 @@ INLINE uint8_t* GetBasePointer(uint32_t Address) return (Memory.SRAM - 0x6000); case MAP_C4: return (Memory.C4RAM - 0x6000); - case MAP_OBC_RAM: - return GetBasePointerOBC1(Address); case MAP_SETA_DSP: return Memory.SRAM; case MAP_DEBUG: diff --git a/source/gfx.c b/source/gfx.c index 5613c49..f4848f3 100644 --- a/source/gfx.c +++ b/source/gfx.c @@ -11,7 +11,6 @@ #include "cheats.h" #define M7 19 -#define M8 19 void ComputeClipWindows(); @@ -699,9 +698,6 @@ static inline void SelectTileRenderer(bool normal) void S9xSetupOBJ() { -#ifdef MK_DEBUG_RTO - if (Settings.BGLayering) fprintf(stderr, "Entering SetupOBJS()\n"); -#endif int SmallWidth, SmallHeight; int LargeWidth, LargeHeight; @@ -749,10 +745,6 @@ void S9xSetupOBJ() SmallHeight >>= 1; LargeHeight >>= 1; } -#ifdef MK_DEBUG_RTO - if (Settings.BGLayering) fprintf(stderr, "Sizes are %dx%d and %dx%d\n", - SmallWidth, SmallHeight, LargeWidth, LargeHeight); -#endif /* OK, we have three cases here. Either there's no priority, priority is * normal FirstSprite, or priority is FirstSprite+Y. The first two are @@ -761,16 +753,8 @@ void S9xSetupOBJ() int Height; uint8_t S; -#ifdef MK_DEBUG_RTO - if (Settings.BGLayering) fprintf(stderr, "Priority rotation=%d, OAMAddr=%d -> ", - PPU.OAMPriorityRotation, PPU.OAMAddr * 2 | (PPU.OAMFlip & 1)); -#endif if (!PPU.OAMPriorityRotation || !(PPU.OAMFlip & PPU.OAMAddr & 1)) { -#ifdef MK_DEBUG_RTO - if (Settings.BGLayering) fprintf(stderr, "normal FirstSprite = %02x\n", - PPU.FirstSprite); -#endif /* normal case */ uint8_t LineOBJ[SNES_HEIGHT_EXTENDED]; memset(LineOBJ, 0, sizeof(LineOBJ)); @@ -811,9 +795,6 @@ void S9xSetupOBJ() if (LineOBJ[Y] >= 32) { GFX.OBJLines[Y].RTOFlags |= 0x40; -#ifdef MK_DEBUG_RTO - if (Settings.BGLayering) fprintf(stderr, "%d: OBJ %02x ranged over\n", Y, S); -#endif continue; } GFX.OBJLines[Y].Tiles -= GFX.OBJVisibleTiles[S]; @@ -846,9 +827,6 @@ void S9xSetupOBJ() else { /* evil FirstSprite+Y case */ -#ifdef MK_DEBUG_RTO - if (Settings.BGLayering) fprintf(stderr, "FirstSprite+Y\n"); -#endif /* First, find out which sprites are on which lines */ uint8_t OBJOnLine[SNES_HEIGHT_EXTENDED][128]; @@ -920,9 +898,6 @@ void S9xSetupOBJ() if (j >= 32) { GFX.OBJLines[Y].RTOFlags |= 0x40; -#ifdef MK_DEBUG_RTO - if (Settings.BGLayering) fprintf(stderr, "%d: OBJ %02x ranged over\n", Y, S); -#endif break; } GFX.OBJLines[Y].Tiles -= GFX.OBJVisibleTiles[S]; @@ -938,34 +913,11 @@ void S9xSetupOBJ() } } -#ifdef MK_DEBUG_RTO - if (Settings.BGLayering) - { - fprintf(stderr, "Sprites per line:\n"); - for (int xxx = 0; xxx < SNES_HEIGHT_EXTENDED; xxx++) - { - fprintf(stderr, "Line %d: RTO=%02x Tiles=%d", xxx, GFX.OBJLines[xxx].RTOFlags, - 34 - GFX.OBJLines[xxx].Tiles); - for (int j = 0; j < 32 && GFX.OBJLines[xxx].OBJ[j].Sprite >= 0; j++) - fprintf(stderr, " %02x.%d", GFX.OBJLines[xxx].OBJ[j].Sprite, - GFX.OBJLines[xxx].OBJ[j].Line); - fprintf(stderr, "\n"); - } - - fprintf(stderr, "Exiting SetupObj()\n"); - } -#endif - IPPU.OBJChanged = false; } static void DrawOBJS(bool OnMain, uint8_t D) { -#ifdef MK_DEBUG_RTO - if (Settings.BGLayering) fprintf(stderr, "Entering DrawOBJS() for %d-%d\n", - GFX.StartY, GFX.EndY); -#endif - BG.BitShift = 4; BG.TileShift = 5; BG.TileAddress = PPU.OBJNameBase; @@ -984,6 +936,7 @@ static void DrawOBJS(bool OnMain, uint8_t D) uint16_t Pos; bool Value; } Windows[7]; + int clipcount = GFX.pCurrentClip->Count [4]; if (!clipcount) { @@ -1027,15 +980,6 @@ static void DrawOBJS(bool OnMain, uint8_t D) } } -#ifdef MK_DEBUG_RTO - if (Settings.BGLayering) - { - fprintf(stderr, "Windows:\n"); - for (int xxx = 0; xxx < 6; xxx++) - fprintf(stderr, "%d: %d = %d\n", xxx, Windows[xxx].Pos, Windows[xxx].Value); - } -#endif - if (Settings.SupportHiRes) { if (PPU.BGMode == 5 || PPU.BGMode == 6) @@ -1082,9 +1026,6 @@ static void DrawOBJS(bool OnMain, uint8_t D) for (Y = GFX.StartY, Offset = Y * GFX.PPL; Y <= GFX.EndY; Y++, Offset += GFX.PPL) { -#ifdef MK_DEBUG_RTO - bool Flag = 0; -#endif int I = 0; #ifdef MK_DISABLE_TIME_OVER int tiles = 0; @@ -1097,32 +1038,7 @@ static void DrawOBJS(bool OnMain, uint8_t D) { tiles += GFX.OBJVisibleTiles[S]; if (tiles <= 0) - { -#ifdef MK_DEBUG_RTO - if (Settings.BGLayering) - { - if (!Flag) - { - Flag = 1; - fprintf(stderr, "Line %d:", Y); - } - fprintf(stderr, " [%02x]", S); - } -#endif continue; - } - -#ifdef MK_DEBUG_RTO - if (Settings.BGLayering) - { - if (!Flag) - { - Flag = 1; - fprintf(stderr, "Line %d:", Y); - } - fprintf(stderr, " %02x", S); - } -#endif if (OnMain && SUB_OR_ADD(4)) SelectTileRenderer(!GFX.Pseudo && PPU.OBJ [S].Palette < 4); @@ -1151,14 +1067,6 @@ static void DrawOBJS(bool OnMain, uint8_t D) && X < PPU.OBJ[S].HPos + GFX.OBJWidths[S]; TileX = (TileX + TileInc) & 0x0f, X += 8, O += 8 * GFX.PixSize) { -#ifdef MK_DEBUG_RTO - if (Settings.BGLayering) - { - if (X < -7) continue; - if ((t - 1) < 0) fprintf(stderr, "-[%d]", 35 - t); - else fprintf(stderr, "-%d", 35 - t); - } -#endif if (X < -7 || --t < 0 || X == 256) continue; if (X >= NextPos) { @@ -1189,14 +1097,7 @@ static void DrawOBJS(bool OnMain, uint8_t D) } } } -#ifdef MK_DEBUG_RTO - if (Settings.BGLayering) if (Flag) fprintf(stderr, "\n"); -#endif } -#ifdef MK_DEBUG_RTO - if (Settings.BGLayering) fprintf(stderr, "Exiting DrawOBJS() for %d-%d\n", - GFX.StartY, GFX.EndY); -#endif } static void DrawBackgroundMosaic(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8_t Z2) @@ -3057,40 +2958,6 @@ static void DrawBGMode7Background16Sub1_2_i(uint8_t* Screen, int bg) theColor, (ScreenColors[b & GFX.Mode7Mask])); } -#define _BUILD_SETUP(F) \ -GFX.BuildPixel = BuildPixel##F; \ -GFX.BuildPixel2 = BuildPixel2##F; \ -GFX.DecomposePixel = DecomposePixel##F; \ -RED_LOW_BIT_MASK = RED_LOW_BIT_MASK_##F; \ -GREEN_LOW_BIT_MASK = GREEN_LOW_BIT_MASK_##F; \ -BLUE_LOW_BIT_MASK = BLUE_LOW_BIT_MASK_##F; \ -RED_HI_BIT_MASK = RED_HI_BIT_MASK_##F; \ -GREEN_HI_BIT_MASK = GREEN_HI_BIT_MASK_##F; \ -BLUE_HI_BIT_MASK = BLUE_HI_BIT_MASK_##F; \ -MAX_RED = MAX_RED_##F; \ -MAX_GREEN = MAX_GREEN_##F; \ -MAX_BLUE = MAX_BLUE_##F; \ -GREEN_HI_BIT = ((MAX_GREEN_##F + 1) >> 1); \ -SPARE_RGB_BIT_MASK = SPARE_RGB_BIT_MASK_##F; \ -RGB_LOW_BITS_MASK = (RED_LOW_BIT_MASK_##F | \ - GREEN_LOW_BIT_MASK_##F | \ - BLUE_LOW_BIT_MASK_##F); \ -RGB_HI_BITS_MASK = (RED_HI_BIT_MASK_##F | \ - GREEN_HI_BIT_MASK_##F | \ - BLUE_HI_BIT_MASK_##F); \ -RGB_HI_BITS_MASKx2 = ((RED_HI_BIT_MASK_##F | \ - GREEN_HI_BIT_MASK_##F | \ - BLUE_HI_BIT_MASK_##F) << 1); \ -RGB_REMOVE_LOW_BITS_MASK = ~RGB_LOW_BITS_MASK; \ -FIRST_COLOR_MASK = FIRST_COLOR_MASK_##F; \ -SECOND_COLOR_MASK = SECOND_COLOR_MASK_##F; \ -THIRD_COLOR_MASK = THIRD_COLOR_MASK_##F; \ -ALPHA_BITS_MASK = ALPHA_BITS_MASK_##F; \ -FIRST_THIRD_COLOR_MASK = FIRST_COLOR_MASK | THIRD_COLOR_MASK; \ -TWO_LOW_BITS_MASK = RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 1); \ -HIGH_BITS_SHIFTED_TWO_MASK = (( (FIRST_COLOR_MASK | SECOND_COLOR_MASK | THIRD_COLOR_MASK) & \ - ~TWO_LOW_BITS_MASK ) >> 2); - static void RenderScreen(uint8_t* Screen, bool sub, bool force_no_add, uint8_t D) { bool BG0; @@ -3251,29 +3118,6 @@ static void RenderScreen(uint8_t* Screen, bool sub, bool force_no_add, uint8_t D } } -#include "font.h" - -void DisplayChar(uint8_t* Screen, uint8_t c) -{ - int line = (((c & 0x7f) - 32) >> 4) * font_height; - int offset = (((c & 0x7f) - 32) & 15) * font_width; - int h, w; - uint16_t* s = (uint16_t*) Screen; - for (h = 0; h < font_height; h++, line++, - s += GFX.PPL - font_width) - { - for (w = 0; w < font_width; w++, s++) - { - uint8_t p = font [line][offset + w]; - - if (p == '#') - *s = Settings.DisplayColor; - else if (p == '.') - *s = BLACK; - } - } -} - void S9xUpdateScreen(void) { int32_t x2 = 1; diff --git a/source/gfx.h b/source/gfx.h index 663a4c3..c840d58 100644 --- a/source/gfx.h +++ b/source/gfx.h @@ -21,56 +21,56 @@ extern struct SGFX GFX; bool S9xInitGFX(); void S9xDeinitGFX(); bool S9xInitUpdate(void); -#define S9xSyncSpeed() - struct SGFX { // Initialize these variables - uint8_t* Screen_buffer; - uint8_t* SubScreen_buffer; - uint8_t* ZBuffer_buffer; - uint8_t* SubZBuffer_buffer; - - uint8_t* Screen; - uint8_t* SubScreen; - uint8_t* ZBuffer; - uint8_t* SubZBuffer; + uint8_t* Screen_buffer; + uint8_t* SubScreen_buffer; + uint8_t* ZBuffer_buffer; + uint8_t* SubZBuffer_buffer; + + uint8_t* Screen; + uint8_t* SubScreen; + uint8_t* ZBuffer; + uint8_t* SubZBuffer; uint32_t Pitch; // Setup in call to S9xInitGFX() - int Delta; - uint16_t* X2; - uint16_t* ZERO_OR_X2; - uint16_t* ZERO; - uint32_t RealPitch; // True pitch of Screen buffer. - uint32_t Pitch2; // Same as RealPitch except while using speed up hack for Glide. - uint32_t ZPitch; // Pitch of ZBuffer - uint32_t PPL; // Number of pixels on each of Screen buffer - uint32_t PPLx2; - uint32_t PixSize; - uint8_t S_safety_margin[8]; - uint8_t* S; - uint8_t DB_safety_margin[8]; - uint8_t* DB; - ptrdiff_t DepthDelta; - uint8_t Z1; // Depth for comparison - uint8_t Z2; // Depth to save - uint8_t ZSprite; // Used to ensure only 1st sprite is drawn per pixel - uint32_t FixedColour; - const char* InfoString; - uint32_t InfoStringTimeout; - uint32_t StartY; - uint32_t EndY; + int Delta; + uint16_t* X2; + uint16_t* ZERO_OR_X2; + uint16_t* ZERO; + uint32_t RealPitch; // True pitch of Screen buffer. + uint32_t Pitch2; // Same as RealPitch except while using speed up hack for Glide. + uint32_t ZPitch; // Pitch of ZBuffer + uint32_t PPL; // Number of pixels on each of Screen buffer + uint32_t PPLx2; + uint32_t PixSize; + uint8_t S_safety_margin[8]; + uint8_t* S; + uint8_t DB_safety_margin[8]; + uint8_t* DB; + ptrdiff_t DepthDelta; + uint8_t Z1; // Depth for comparison + uint8_t Z2; // Depth to save + uint8_t ZSprite; // Used to ensure only 1st sprite is drawn per pixel + uint32_t FixedColour; + const char* InfoString; + uint32_t InfoStringTimeout; + uint32_t StartY; + uint32_t EndY; struct ClipData* pCurrentClip; - uint32_t Mode7Mask; - uint32_t Mode7PriorityMask; - uint8_t OBJWidths[128]; - uint8_t OBJVisibleTiles[128]; + uint32_t Mode7Mask; + uint32_t Mode7PriorityMask; + uint8_t OBJWidths[128]; + uint8_t OBJVisibleTiles[128]; + struct { uint8_t RTOFlags; int16_t Tiles; + struct { int8_t Sprite; @@ -78,12 +78,11 @@ struct SGFX } OBJ[32]; } OBJLines [SNES_HEIGHT_EXTENDED]; - uint8_t r212c; - uint8_t r212d; - uint8_t r2130; - uint8_t r2131; - bool Pseudo; - + uint8_t r212c; + uint8_t r212d; + uint8_t r2130; + uint8_t r2131; + bool Pseudo; }; struct SLineData @@ -114,7 +113,7 @@ typedef struct uint8_t* Buffer; uint8_t* Buffered; - bool DirectColourMode; + bool DirectColourMode; } SBG; struct SLineMatrixData @@ -224,4 +223,3 @@ typedef void (*LargePixelRenderer)(uint32_t Tile, int32_t Offset, uint32_t StartLine, uint32_t LineCount); #endif - diff --git a/source/globals.c b/source/globals.c index 07df507..83adf78 100644 --- a/source/globals.c +++ b/source/globals.c @@ -35,13 +35,10 @@ SDSP1 DSP1; SSA1 SA1; - - SnesModel M1SNES = {1, 3, 2}; SnesModel M2SNES = {2, 4, 3}; SnesModel* Model = &M1SNES; - uint8_t* C4RAM = NULL; long OpAddress = 0; diff --git a/source/memmap.c b/source/memmap.c index a91f68e..81093df 100644 --- a/source/memmap.c +++ b/source/memmap.c @@ -35,16 +35,6 @@ extern struct FxInit_s SuperFX; #define SET_UI_COLOR(r,g,b) ; #endif -//you would think everyone would have these -//since they're so useful. -#ifndef max -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif - -#ifndef min -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif - static int retry_count = 0; static uint8_t bytes0x2000 [0x2000]; int is_bsx(unsigned char*); @@ -111,8 +101,6 @@ const uint32_t crc32Table[256] = 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d }; - - void S9xDeinterleaveType1(int TotalFileSize, uint8_t* base) { if (Settings.DisplayColor == 0xffff) @@ -401,11 +389,6 @@ bool S9xInitMemory() void S9xDeinitMemory() { -#ifdef __W32_HEAP - if (_HEAPOK != _heapchk()) - MessageBox(GUI.hWnd, "Deinit", "Heap Corrupt", MB_OK); -#endif - if (Memory.RAM) { free((char*) Memory.RAM); @@ -929,7 +912,7 @@ again: //set swapped here. - if (max(swappedlorom, swappedhirom) >= max(loromscore, hiromscore)) + if (MAX(swappedlorom, swappedhirom) >= MAX(loromscore, hiromscore)) { Memory.ExtendedFormat = BIGFIRST; hi_score = swappedhirom; @@ -1032,7 +1015,6 @@ again: { S9xDeinterleaveType1(Memory.CalculatedSize - 0x400000, Memory.ROM); S9xDeinterleaveType1(0x400000, Memory.ROM + Memory.CalculatedSize - 0x400000); - } Memory.LoROM = false; @@ -1410,7 +1392,6 @@ void InitROM(bool Interleaved) size = 1 << power2; uint32_t remainder = Memory.CalculatedSize - size; - int i; for (i = 0; i < size; i++) @@ -1435,11 +1416,9 @@ void InitROM(bool Interleaved) sum1 -= sub; } - if (remainder) sum1 += sum2 * (size / remainder); - sum1 &= 0xffff; Memory.CalculatedChecksum = sum1; } @@ -1548,12 +1527,9 @@ void FixROMSpeed() if (CPU.FastROMSpeed == 0) CPU.FastROMSpeed = SLOW_ONE_CYCLE; - for (c = 0x800; c < 0x1000; c++) - { if (c & 0x8 || c & 0x400) Memory.MemorySpeed [c] = (uint8_t) CPU.FastROMSpeed; - } } @@ -2254,7 +2230,7 @@ void TalesROMMap(bool Interleaved) if ((strncmp("TALES", (char*)Memory.Map[8] + 0xFFC0, 5) == 0)) { - if (((*(Memory.Map[8] + 0xFFDE)) == (*(Memory.Map[0x808] + 0xFFDE)))) + if (*(Memory.Map[8] + 0xFFDE) == *(Memory.Map[0x808] + 0xFFDE)) { Settings.DisplayColor = BUILD_PIXEL(31, 0, 0); SET_UI_COLOR(255, 0, 0); @@ -3075,20 +3051,6 @@ const char* ROMID() void ApplyROMFixes() { -#ifdef __W32_HEAP - if (_HEAPOK != _heapchk()) - MessageBox(GUI.hWnd, "ApplyROMFixes", "Heap Corrupt", MB_OK); -#endif - - //don't steal my work! -MK - if (Memory.ROMCRC32 == 0x1B4A5616 - && strncmp(Memory.ROMName, "RUDORA NO HIHOU", 15) == 0) - { - strncpy(Memory.ROMName, "THIS SCRIPT WAS STOLEN", 22); - Settings.DisplayColor = BUILD_PIXEL(31, 0, 0); - SET_UI_COLOR(255, 0, 0); - } - /* HACKS NSRT can fix that we hadn't detected before. [14:25:13] <@Nach> case 0x0c572ef0: //So called Hook (US)(2648) @@ -3213,7 +3175,6 @@ void ApplyROMFixes() LoROMMap(); } - //NMI hacks CPU.NMITriggerPoint = 4; if (strcmp(Memory.ROMName, "CACOMA KNIGHT") == 0) @@ -3232,7 +3193,6 @@ void ApplyROMFixes() strncmp(Memory.ROMName, "WAR 2410", 8) == 0) Settings.Shutdown = false; - //APU timing hacks #ifndef USE_BLARGG_APU @@ -3243,7 +3203,6 @@ void ApplyROMFixes() strcmp(Memory.ROMName, "GAIA GENSOUKI 1 JPN") == 0) IAPU.OneCycle = 13; - // RENDERING RANGER R2 if (strcmp(Memory.ROMId, "AVCJ") == 0 || //Mark Davis @@ -3321,7 +3280,6 @@ void ApplyROMFixes() if (strncmp(Memory.ROMName, "UNIRACERS", 9) == 0) SNESGameFixes.Uniracers = true; - //is this even useful now? if (strcmp(Memory.ROMName, "ALIENS vs. PREDATOR") == 0) SNESGameFixes.alienVSpredetorFix = true; @@ -3361,7 +3319,6 @@ void ApplyROMFixes() strncmp(Memory.ROMId, "AJE", 3) == 0) Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 103) / 100; - if (strncmp(Memory.ROMId, "A3M", 3) == 0 && Settings.CyclesPercentage == 100) // Mortal Kombat 3. Fixes cut off speech sample Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 110) / 100; @@ -3378,7 +3335,6 @@ void ApplyROMFixes() Settings.CyclesPercentage == 100) Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 101) / 100; - #ifdef DETECT_NASTY_FX_INTERLEAVE //XXX: Test without these. Win32 port indicates they aren't needed? //Apparently are needed! @@ -3393,7 +3349,6 @@ void ApplyROMFixes() if (strncmp(Memory.ROMId, "A9D", 3) == 0 && Settings.CyclesPercentage == 100) Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 110) / 100; - //SA-1 Speedup settings SA1.WaitAddress = NULL; SA1.WaitByteAddress1 = NULL; @@ -3557,7 +3512,6 @@ void ApplyROMFixes() SA1.WaitByteAddress2 = Memory.SRAM + 0x0808; } - //Other // Additional game fixes by sanmaiwashi ... @@ -3571,7 +3525,6 @@ void ApplyROMFixes() SNESGameFixes.SRAMInitialValue = 0x6b; } - // HITOMI3 if (strcmp(Memory.ROMName, "HITOMI3") == 0) { @@ -3615,8 +3568,6 @@ void ApplyROMFixes() //BNE } - - int is_bsx(unsigned char* p) { unsigned c; diff --git a/source/memmap.h b/source/memmap.h index 788c30a..3a77033 100644 --- a/source/memmap.h +++ b/source/memmap.h @@ -111,37 +111,37 @@ typedef struct uint8_t* BWRAM; uint8_t* FillRAM; uint8_t* C4RAM; - bool HiROM; - bool LoROM; + bool HiROM; + bool LoROM; uint32_t SRAMMask; - uint8_t SRAMSize; + uint8_t SRAMSize; uint8_t* Map [MEMMAP_NUM_BLOCKS]; uint8_t* WriteMap [MEMMAP_NUM_BLOCKS]; - uint8_t MemorySpeed [MEMMAP_NUM_BLOCKS]; - uint8_t BlockIsRAM [MEMMAP_NUM_BLOCKS]; - uint8_t BlockIsROM [MEMMAP_NUM_BLOCKS]; - char ROMName [ROM_NAME_LEN]; - char ROMId [5]; - char CompanyId [3]; - uint8_t ROMSpeed; - uint8_t ROMType; - uint8_t ROMSize; - int32_t ROMFramesPerSecond; - int32_t HeaderCount; + uint8_t MemorySpeed [MEMMAP_NUM_BLOCKS]; + uint8_t BlockIsRAM [MEMMAP_NUM_BLOCKS]; + uint8_t BlockIsROM [MEMMAP_NUM_BLOCKS]; + char ROMName [ROM_NAME_LEN]; + char ROMId [5]; + char CompanyId [3]; + uint8_t ROMSpeed; + uint8_t ROMType; + uint8_t ROMSize; + int32_t ROMFramesPerSecond; + int32_t HeaderCount; uint32_t CalculatedSize; uint32_t CalculatedChecksum; uint32_t ROMChecksum; uint32_t ROMComplementChecksum; - uint8_t* SDD1Index; - uint8_t* SDD1Data; + uint8_t* SDD1Index; + uint8_t* SDD1Data; uint32_t SDD1Entries; uint32_t SDD1LoggedDataCountPrev; uint32_t SDD1LoggedDataCount; uint8_t SDD1LoggedData [MEMMAP_MAX_SDD1_LOGGED_ENTRIES]; - char ROMFilename [_MAX_PATH]; - uint8_t ROMRegion; + char ROMFilename [_MAX_PATH]; + uint8_t ROMRegion; uint32_t ROMCRC32; - uint8_t ExtendedFormat; + uint8_t ExtendedFormat; uint8_t* BSRAM; } CMemory; diff --git a/source/missing.h b/source/missing.h index 9a8b711..98d99cb 100644 --- a/source/missing.h +++ b/source/missing.h @@ -5,73 +5,72 @@ struct HDMA { - uint8_t used; - uint8_t bbus_address; - uint8_t abus_bank; + uint8_t used; + uint8_t bbus_address; + uint8_t abus_bank; uint16_t abus_address; - uint8_t indirect_address; - uint8_t force_table_address_write; - uint8_t force_table_address_read; - uint8_t line_count_write; - uint8_t line_count_read; + uint8_t indirect_address; + uint8_t force_table_address_write; + uint8_t force_table_address_read; + uint8_t line_count_write; + uint8_t line_count_read; }; struct Missing { - uint8_t emulate6502; - uint8_t decimal_mode; - uint8_t mv_8bit_index; - uint8_t mv_8bit_acc; - uint8_t interlace; - uint8_t lines_239; - uint8_t pseudo_512; + uint8_t emulate6502; + uint8_t decimal_mode; + uint8_t mv_8bit_index; + uint8_t mv_8bit_acc; + uint8_t interlace; + uint8_t lines_239; + uint8_t pseudo_512; struct HDMA hdma [8]; - uint8_t modes [8]; - uint8_t mode7_fx; - uint8_t mode7_flip; - uint8_t mode7_bgmode; - uint8_t direct; - uint8_t matrix_multiply; - uint8_t oam_read; - uint8_t vram_read; - uint8_t cgram_read; - uint8_t wram_read; - uint8_t dma_read; - uint8_t vram_inc; - uint8_t vram_full_graphic_inc; - uint8_t virq; - uint8_t hirq; - uint16_t virq_pos; - uint16_t hirq_pos; - uint8_t h_v_latch; - uint8_t h_counter_read; - uint8_t v_counter_read; - uint8_t fast_rom; - uint8_t window1 [6]; - uint8_t window2 [6]; - uint8_t sprite_priority_rotation; - uint8_t subscreen; - uint8_t subscreen_add; - uint8_t subscreen_sub; - uint8_t fixed_colour_add; - uint8_t fixed_colour_sub; - uint8_t mosaic; - uint8_t sprite_double_height; - uint8_t dma_channels; - uint8_t dma_this_frame; - uint8_t oam_address_read; - uint8_t bg_offset_read; - uint8_t matrix_read; - uint8_t hdma_channels; - uint8_t hdma_this_frame; - uint16_t unknownppu_read; - uint16_t unknownppu_write; - uint16_t unknowncpu_read; - uint16_t unknowncpu_write; - uint16_t unknowndsp_read; - uint16_t unknowndsp_write; + uint8_t modes [8]; + uint8_t mode7_fx; + uint8_t mode7_flip; + uint8_t mode7_bgmode; + uint8_t direct; + uint8_t matrix_multiply; + uint8_t oam_read; + uint8_t vram_read; + uint8_t cgram_read; + uint8_t wram_read; + uint8_t dma_read; + uint8_t vram_inc; + uint8_t vram_full_graphic_inc; + uint8_t virq; + uint8_t hirq; + uint16_t virq_pos; + uint16_t hirq_pos; + uint8_t h_v_latch; + uint8_t h_counter_read; + uint8_t v_counter_read; + uint8_t fast_rom; + uint8_t window1 [6]; + uint8_t window2 [6]; + uint8_t sprite_priority_rotation; + uint8_t subscreen; + uint8_t subscreen_add; + uint8_t subscreen_sub; + uint8_t fixed_colour_add; + uint8_t fixed_colour_sub; + uint8_t mosaic; + uint8_t sprite_double_height; + uint8_t dma_channels; + uint8_t dma_this_frame; + uint8_t oam_address_read; + uint8_t bg_offset_read; + uint8_t matrix_read; + uint8_t hdma_channels; + uint8_t hdma_this_frame; + uint16_t unknownppu_read; + uint16_t unknownppu_write; + uint16_t unknowncpu_read; + uint16_t unknowncpu_write; + uint16_t unknowndsp_read; + uint16_t unknowndsp_write; }; struct Missing missing; #endif - diff --git a/source/obc1.c b/source/obc1.c index 0013e33..f0afdd4 100644 --- a/source/obc1.c +++ b/source/obc1.c @@ -95,11 +95,6 @@ void SetOBC1(uint8_t Byte, uint16_t Address) } } -uint8_t* GetBasePointerOBC1(uint32_t Address) -{ - return Memory.FillRAM; -} - uint8_t* GetMemPointerOBC1(uint32_t Address) { return (Memory.FillRAM + (Address & 0xffff)); diff --git a/source/obc1.h b/source/obc1.h index 7d478f0..e781f5b 100644 --- a/source/obc1.h +++ b/source/obc1.h @@ -5,9 +5,7 @@ uint8_t GetOBC1(uint16_t Address); void SetOBC1(uint8_t Byte, uint16_t Address); -uint8_t* GetBasePointerOBC1(uint32_t Address); uint8_t* GetMemPointerOBC1(uint32_t Address); void ResetOBC1(); #endif - diff --git a/source/pixform.h b/source/pixform.h index 1e4b95f..1a8c917 100644 --- a/source/pixform.h +++ b/source/pixform.h @@ -198,4 +198,3 @@ ~TWO_LOW_BITS_MASK ) >> 2) #endif - diff --git a/source/port.h b/source/port.h index 125d656..b887fe1 100644 --- a/source/port.h +++ b/source/port.h @@ -8,7 +8,6 @@ #include <string.h> #include <sys/types.h> -/* #define PIXEL_FORMAT RGB565 */ #ifdef PSP #define PIXEL_FORMAT BGR555 #else @@ -40,8 +39,6 @@ void _splitpath(const char* path, char* drive, char* dir, char* fname, #define strncasecmp strnicmp #endif -void S9xGenerateSound(void); - #define SLASH_STR "/" #define SLASH_CHAR '/' @@ -56,5 +53,7 @@ void S9xGenerateSound(void); #include <libretro.h> -#endif +#define MIN(A,B) ((A) < (B) ? (A) : (B)) +#define MAX(A,B) ((A) > (B) ? (A) : (B)) +#endif diff --git a/source/ppu.c b/source/ppu.c index bc94e6e..8dcb52b 100644 --- a/source/ppu.c +++ b/source/ppu.c @@ -7,7 +7,6 @@ #include "missing.h" #include "apu.h" #include "dma.h" -#include "gfx.h" #include "display.h" #include "sa1.h" #include "sdd1.h" @@ -17,6 +16,7 @@ #include "fxemu.h" #include "fxinst.h" extern struct FxInit_s SuperFX; +extern uint8_t mul_brightness [16][32]; uint32_t justifiers = 0xFFFF00AA; uint8_t in_bit = 0; diff --git a/source/ppu.h b/source/ppu.h index 22d225a..7ad3489 100644 --- a/source/ppu.h +++ b/source/ppu.h @@ -31,52 +31,52 @@ struct ClipData typedef struct { - bool ColorsChanged; + bool ColorsChanged; uint8_t HDMA; - bool HDMAStarted; + bool HDMAStarted; uint8_t MaxBrightness; - bool LatchedBlanking; - bool OBJChanged; - bool RenderThisFrame; - bool DirectColourMapsNeedRebuild; + bool LatchedBlanking; + bool OBJChanged; + bool RenderThisFrame; + bool DirectColourMapsNeedRebuild; uint32_t FrameCount; uint32_t RenderedFramesCount; uint32_t DisplayedRenderedFrameCount; uint32_t SkippedFrames; uint32_t FrameSkip; - uint8_t* TileCache [3]; - uint8_t* TileCached [3]; + uint8_t* TileCache [3]; + uint8_t* TileCached [3]; #ifdef CORRECT_VRAM_READS uint16_t VRAMReadBuffer; #else bool FirstVRAMRead; #endif - bool DoubleHeightPixels; - bool Interlace; - bool InterlaceSprites; - bool DoubleWidthPixels; - bool HalfWidthPixels; - int RenderedScreenHeight; - int RenderedScreenWidth; - uint32_t Red [256]; - uint32_t Green [256]; - uint32_t Blue [256]; - uint8_t* XB; - uint16_t ScreenColors [256]; - int PreviousLine; - int CurrentLine; - int Controller; - uint32_t Joypads[5]; - uint32_t SuperScope; - uint32_t Mouse[2]; - int PrevMouseX[2]; - int PrevMouseY[2]; + bool DoubleHeightPixels; + bool Interlace; + bool InterlaceSprites; + bool DoubleWidthPixels; + bool HalfWidthPixels; + int RenderedScreenHeight; + int RenderedScreenWidth; + uint32_t Red [256]; + uint32_t Green [256]; + uint32_t Blue [256]; + uint8_t* XB; + uint16_t ScreenColors [256]; + int PreviousLine; + int CurrentLine; + int Controller; + uint32_t Joypads[5]; + uint32_t SuperScope; + uint32_t Mouse[2]; + int PrevMouseX[2]; + int PrevMouseY[2]; struct ClipData Clip [2]; } InternalPPU; struct SOBJ { - short HPos; + short HPos; uint16_t VPos; uint16_t Name; uint8_t VFlip; @@ -88,14 +88,14 @@ struct SOBJ typedef struct { - uint8_t BGMode; - uint8_t BG3Priority; - uint8_t Brightness; + uint8_t BGMode; + uint8_t BG3Priority; + uint8_t Brightness; struct { - bool High; - uint8_t Increment; + bool High; + uint8_t Increment; uint16_t Address; uint16_t Mask1; uint16_t FullGraphicCount; @@ -107,19 +107,19 @@ typedef struct uint16_t SCBase; uint16_t VOffset; uint16_t HOffset; - uint8_t BGSize; + uint8_t BGSize; uint16_t NameBase; uint16_t SCSize; } BG [4]; - bool CGFLIP; - uint16_t CGDATA [256]; - uint8_t FirstSprite; - uint8_t LastSprite; + bool CGFLIP; + uint16_t CGDATA [256]; + uint8_t FirstSprite; + uint8_t LastSprite; struct SOBJ OBJ [128]; - uint8_t OAMPriorityRotation; - uint16_t OAMAddr; - uint8_t RangeTimeOver; + uint8_t OAMPriorityRotation; + uint16_t OAMAddr; + uint8_t RangeTimeOver; uint8_t OAMFlip; uint16_t OAMTileAddress; @@ -128,18 +128,18 @@ typedef struct uint16_t VBeamPosLatched; uint16_t HBeamPosLatched; - uint8_t HBeamFlip; - uint8_t VBeamFlip; - uint8_t HVBeamCounterLatched; + uint8_t HBeamFlip; + uint8_t VBeamFlip; + uint8_t HVBeamCounterLatched; - short MatrixA; - short MatrixB; - short MatrixC; - short MatrixD; - short CentreX; - short CentreY; - uint8_t Joypad1ButtonReadPos; - uint8_t Joypad2ButtonReadPos; + short MatrixA; + short MatrixB; + short MatrixC; + short MatrixD; + short CentreX; + short CentreY; + uint8_t Joypad1ButtonReadPos; + uint8_t Joypad2ButtonReadPos; uint8_t CGADD; uint8_t FixedColourRed; @@ -149,21 +149,21 @@ typedef struct uint16_t ScreenHeight; uint32_t WRAM; uint8_t BG_Forced; - bool ForcedBlanking; - bool OBJThroughMain; - bool OBJThroughSub; + bool ForcedBlanking; + bool OBJThroughMain; + bool OBJThroughSub; uint8_t OBJSizeSelect; uint16_t OBJNameBase; - bool OBJAddition; + bool OBJAddition; uint8_t OAMReadFlip; uint8_t OAMData [512 + 32]; - bool VTimerEnabled; - bool HTimerEnabled; - short HTimerPosition; + bool VTimerEnabled; + bool HTimerEnabled; + short HTimerPosition; uint8_t Mosaic; - bool BGMosaic [4]; - bool Mode7HFlip; - bool Mode7VFlip; + bool BGMosaic [4]; + bool Mode7HFlip; + bool Mode7VFlip; uint8_t Mode7Repeat; uint8_t Window1Left; uint8_t Window1Right; @@ -173,20 +173,20 @@ typedef struct uint8_t ClipWindowOverlapLogic [6]; uint8_t ClipWindow1Enable [6]; uint8_t ClipWindow2Enable [6]; - bool ClipWindow1Inside [6]; - bool ClipWindow2Inside [6]; - bool RecomputeClipWindows; + bool ClipWindow1Inside [6]; + bool ClipWindow2Inside [6]; + bool RecomputeClipWindows; uint8_t CGFLIPRead; uint16_t OBJNameSelect; - bool Need16x8Mulitply; + bool Need16x8Mulitply; uint8_t Joypad3ButtonReadPos; uint8_t MouseSpeed[2]; // XXX Do these need to be added to snapshot.cpp? uint16_t OAMWriteRegister; - uint8_t BGnxOFSbyte; - uint8_t OpenBus1; - uint8_t OpenBus2; + uint8_t BGnxOFSbyte; + uint8_t OpenBus1; + uint8_t OpenBus2; } SPPU; #define CLIP_OR 0 @@ -196,10 +196,10 @@ typedef struct typedef struct { - bool TransferDirection; - bool AAddressFixed; - bool AAddressDecrement; - uint8_t TransferMode; + bool TransferDirection; + bool AAddressFixed; + bool AAddressDecrement; + uint8_t TransferMode; uint8_t ABank; uint16_t AAddress; @@ -210,7 +210,7 @@ typedef struct uint16_t TransferBytes; // H-DMA only: - bool HDMAIndirectAddressing; + bool HDMAIndirectAddressing; uint16_t IndirectAddress; uint8_t IndirectBank; uint8_t Repeat; @@ -241,7 +241,6 @@ extern SPPU PPU; extern SDMA DMA [8]; extern InternalPPU IPPU; -#include "gfx.h" #include "memmap.h" typedef struct @@ -276,4 +275,3 @@ void JustifierButtons(uint32_t*); bool JustifierOffscreen(); #endif - diff --git a/source/sa1.c b/source/sa1.c index 18540fb..ac423f5 100644 --- a/source/sa1.c +++ b/source/sa1.c @@ -735,4 +735,3 @@ void S9xSA1ReadVariableLengthData(bool inc, bool no_shift) Memory.FillRAM [0x225b] = (uint8_t)(addr >> 16); } } - diff --git a/source/sa1.h b/source/sa1.h index 84ec94a..0958fc2 100644 --- a/source/sa1.h +++ b/source/sa1.h @@ -10,49 +10,49 @@ typedef struct { uint8_t PB; uint8_t DB; - pair P; - pair A; - pair D; - pair S; - pair X; - pair Y; + pair P; + pair A; + pair D; + pair S; + pair X; + pair Y; uint16_t PC; } SSA1Registers; typedef struct { - SOpcodes* S9xOpcodes; - uint8_t _Carry; - uint8_t _Zero; - uint8_t _Negative; - uint8_t _Overflow; - bool CPUExecuting; - uint32_t ShiftedPB; - uint32_t ShiftedDB; - uint32_t Flags; - bool Executing; - bool NMIActive; - uint8_t IRQActive; - bool WaitingForInterrupt; - bool Waiting; - uint8_t* PC; - uint8_t* PCBase; - uint8_t* BWRAM; - uint8_t* PCAtOpcodeStart; - uint8_t* WaitAddress; - uint32_t WaitCounter; - uint8_t* WaitByteAddress1; - uint8_t* WaitByteAddress2; - uint8_t* Map [MEMMAP_NUM_BLOCKS]; - uint8_t* WriteMap [MEMMAP_NUM_BLOCKS]; - int16_t op1; - int16_t op2; - int arithmetic_op; - int64_t sum; - bool overflow; - uint8_t VirtualBitmapFormat; - bool in_char_dma; - uint8_t variable_bit_pos; + SOpcodes* S9xOpcodes; + uint8_t _Carry; + uint8_t _Zero; + uint8_t _Negative; + uint8_t _Overflow; + bool CPUExecuting; + uint32_t ShiftedPB; + uint32_t ShiftedDB; + uint32_t Flags; + bool Executing; + bool NMIActive; + uint8_t IRQActive; + bool WaitingForInterrupt; + bool Waiting; + uint8_t* PC; + uint8_t* PCBase; + uint8_t* BWRAM; + uint8_t* PCAtOpcodeStart; + uint8_t* WaitAddress; + uint32_t WaitCounter; + uint8_t* WaitByteAddress1; + uint8_t* WaitByteAddress2; + uint8_t* Map [MEMMAP_NUM_BLOCKS]; + uint8_t* WriteMap [MEMMAP_NUM_BLOCKS]; + int16_t op1; + int16_t op2; + int arithmetic_op; + int64_t sum; + bool overflow; + uint8_t VirtualBitmapFormat; + bool in_char_dma; + uint8_t variable_bit_pos; SSA1Registers Registers; } SSA1; @@ -70,7 +70,6 @@ typedef struct #define SA1SetFlags(f) (SA1.Registers.P.W |= (f)) #define SA1CheckFlag(f) (SA1.Registers.PL & (f)) - uint8_t S9xSA1GetByte(uint32_t); uint16_t S9xSA1GetWord(uint32_t); void S9xSA1SetByte(uint8_t, uint32_t); @@ -128,4 +127,3 @@ static inline void S9xSA1FixCycles(void) } } #endif - diff --git a/source/sa1cpu.c b/source/sa1cpu.c index 40cbd0e..baaa929 100644 --- a/source/sa1cpu.c +++ b/source/sa1cpu.c @@ -142,4 +142,3 @@ void S9xSA1MainLoop() (*SA1.S9xOpcodes [*SA1.PC++].S9xOpcode)(); } } - diff --git a/source/sar.h b/source/sar.h index 82722a4..4ab4ecb 100644 --- a/source/sar.h +++ b/source/sar.h @@ -51,4 +51,3 @@ static inline int64_t SAR64(const int64_t b, const int n) #endif #endif - diff --git a/source/sdd1.h b/source/sdd1.h index 6a8c251..7f1df83 100644 --- a/source/sdd1.h +++ b/source/sdd1.h @@ -8,4 +8,3 @@ void S9xResetSDD1(); void S9xSDD1PostLoadState(); #endif - diff --git a/source/seta.c b/source/seta.c index c9ca72f..0195955 100644 --- a/source/seta.c +++ b/source/seta.c @@ -14,4 +14,3 @@ void S9xSetSetaDSP(uint8_t Byte, uint32_t Address) { SetSETA(Address, Byte); } - diff --git a/source/seta.h b/source/seta.h index ffdecab..9c3e78b 100644 --- a/source/seta.h +++ b/source/seta.h @@ -29,37 +29,36 @@ typedef struct SETA_ST010_STRUCT uint8_t output_params[16]; uint8_t op_reg; uint8_t execute; - bool control_enable; + bool control_enable; } ST010_Regs; typedef struct SETA_ST011_STRUCT { - bool waiting4command; - uint8_t status; - uint8_t command; + bool waiting4command; + uint8_t status; + uint8_t command; uint32_t in_count; uint32_t in_index; uint32_t out_count; uint32_t out_index; - uint8_t parameters [512]; - uint8_t output [512]; + uint8_t parameters [512]; + uint8_t output [512]; } ST011_Regs; typedef struct SETA_ST018_STRUCT { - bool waiting4command; - uint8_t status; - uint8_t part_command; - uint8_t pass; + bool waiting4command; + uint8_t status; + uint8_t part_command; + uint8_t pass; uint32_t command; uint32_t in_count; uint32_t in_index; uint32_t out_count; uint32_t out_index; - uint8_t parameters [512]; - uint8_t output [512]; + uint8_t parameters [512]; + uint8_t output [512]; } ST018_Regs; #endif #endif - diff --git a/source/seta010.c b/source/seta010.c index 856e700..b9ce7c3 100644 --- a/source/seta010.c +++ b/source/seta010.c @@ -36,10 +36,6 @@ bool seta_hack; //temporary Op04 requirement #include <math.h> -#ifndef PI -#define PI 3.1415926535897932384626433832795 -#endif - ST010_Regs ST010; uint8_t S9xGetST010(uint32_t Address) @@ -288,12 +284,6 @@ void ST010_Rotate(int16_t Theta, int16_t X0, int16_t Y0, int16_t* X1, int16_t* Y *Y1 = (Y0 * ST010_Cos(Theta) >> 15) - (X0 * ST010_Sin(Theta) >> 15); } -void SETA_Distance(int16_t Y0, int16_t X0, int16_t* Distance) -{ - if (X0 < 0) X0 = -X0; - *Distance = ((X0 * 0x7af0) + 0x4000) >> 15; -} - void ST010_SortDrivers(uint16_t Positions, uint16_t Places[32], uint16_t Drivers[32]) { bool Sorted; @@ -331,7 +321,6 @@ void S9xSetST010(uint32_t Address, uint8_t Byte) ST010.control_enable = true; return; } - //printf("Write %06X:%02X\n", Address, Byte); if ((Address & 0xFFF) == 0x20 && ST010.control_enable) ST010.op_reg = Byte; @@ -574,7 +563,6 @@ void S9xSetST010(uint32_t Address, uint8_t Byte) y = Memory.SRAM[2] | (Memory.SRAM[3] << 8); #endif square = (int16_t)sqrt((double)(y * y + x * x)); - //SETA_Distance( x,y,square ); #if defined(FAST_LSB_WORD_ACCESS) && !defined(ANDROID) /* TODO - FIXME */ @@ -743,4 +731,3 @@ void S9xSetST010(uint32_t Address, uint8_t Byte) ST010.execute = 0; } } - diff --git a/source/seta011.c b/source/seta011.c index ef49c21..c2f2f3d 100644 --- a/source/seta011.c +++ b/source/seta011.c @@ -140,4 +140,3 @@ void S9xSetST011(uint32_t Address, uint8_t Byte) } } } - diff --git a/source/seta018.c b/source/seta018.c index 2ae40c0..b385adf 100644 --- a/source/seta018.c +++ b/source/seta018.c @@ -135,4 +135,3 @@ void S9xSetST018(uint8_t Byte, uint32_t Address) } } } - diff --git a/source/snes9x.h b/source/snes9x.h index 4da02bc..de67001 100644 --- a/source/snes9x.h +++ b/source/snes9x.h @@ -53,29 +53,29 @@ extern int cprintf(const char* fmt, ...); * 64.281us / (1 / 3.546895MHz) -> 228 cycles per scanline. */ #define SNES_SCANLINE_TIME (63.695e-6) -#define SNES_CLOCK_SPEED (3579545) +#define SNES_CLOCK_SPEED (3579545u) #define SNES_CLOCK_LEN (1.0 / SNES_CLOCK_SPEED) #define SNES_CYCLES_PER_SCANLINE ((uint32_t) ((SNES_SCANLINE_TIME / SNES_CLOCK_LEN) * 6 + 0.5)) -#define ONE_CYCLE 6 -#define SLOW_ONE_CYCLE 8 -#define TWO_CYCLES 12 +#define ONE_CYCLE 6u +#define SLOW_ONE_CYCLE 8u +#define TWO_CYCLES 12u -#define SNES_TR_MASK (1 << 4) -#define SNES_TL_MASK (1 << 5) -#define SNES_X_MASK (1 << 6) -#define SNES_A_MASK (1 << 7) -#define SNES_RIGHT_MASK (1 << 8) -#define SNES_LEFT_MASK (1 << 9) -#define SNES_DOWN_MASK (1 << 10) -#define SNES_UP_MASK (1 << 11) -#define SNES_START_MASK (1 << 12) -#define SNES_SELECT_MASK (1 << 13) -#define SNES_Y_MASK (1 << 14) -#define SNES_B_MASK (1 << 15) +#define SNES_TR_MASK (1u << 4) +#define SNES_TL_MASK (1u << 5) +#define SNES_X_MASK (1u << 6) +#define SNES_A_MASK (1u << 7) +#define SNES_RIGHT_MASK (1u << 8) +#define SNES_LEFT_MASK (1u << 9) +#define SNES_DOWN_MASK (1u << 10) +#define SNES_UP_MASK (1u << 11) +#define SNES_START_MASK (1u << 12) +#define SNES_SELECT_MASK (1u << 13) +#define SNES_Y_MASK (1u << 14) +#define SNES_B_MASK (1u << 15) enum { @@ -88,179 +88,179 @@ enum SNES_MAX_CONTROLLER_OPTIONS }; -#define DEBUG_MODE_FLAG (1 << 0) -#define TRACE_FLAG (1 << 1) -#define SINGLE_STEP_FLAG (1 << 2) -#define BREAK_FLAG (1 << 3) -#define SCAN_KEYS_FLAG (1 << 4) -#define SAVE_SNAPSHOT_FLAG (1 << 5) -#define DELAYED_NMI_FLAG (1 << 6) -#define NMI_FLAG (1 << 7) -#define PROCESS_SOUND_FLAG (1 << 8) -#define FRAME_ADVANCE_FLAG (1 << 9) -#define DELAYED_NMI_FLAG2 (1 << 10) -#define IRQ_PENDING_FLAG (1 << 11) +#define DEBUG_MODE_FLAG (1u << 0) +#define TRACE_FLAG (1u << 1) +#define SINGLE_STEP_FLAG (1u << 2) +#define BREAK_FLAG (1u << 3) +#define SCAN_KEYS_FLAG (1u << 4) +#define SAVE_SNAPSHOT_FLAG (1u << 5) +#define DELAYED_NMI_FLAG (1u << 6) +#define NMI_FLAG (1u << 7) +#define PROCESS_SOUND_FLAG (1u << 8) +#define FRAME_ADVANCE_FLAG (1u << 9) +#define DELAYED_NMI_FLAG2 (1u << 10) +#define IRQ_PENDING_FLAG (1u << 11) typedef struct { - uint32_t Flags; - bool BranchSkip; - bool NMIActive; - uint8_t IRQActive; - bool WaitingForInterrupt; - bool InDMA; - uint8_t WhichEvent; - uint8_t* PC; - uint8_t* PCBase; - uint8_t* PCAtOpcodeStart; - uint8_t* WaitAddress; - uint32_t WaitCounter; - long Cycles; - long NextEvent; - long V_Counter; - long MemSpeed; - long MemSpeedx2; - long FastROMSpeed; + uint32_t Flags; + bool BranchSkip; + bool NMIActive; + uint8_t IRQActive; + bool WaitingForInterrupt; + bool InDMA; + uint8_t WhichEvent; + uint8_t* PC; + uint8_t* PCBase; + uint8_t* PCAtOpcodeStart; + uint8_t* WaitAddress; + uint32_t WaitCounter; + long Cycles; + long NextEvent; + long V_Counter; + long MemSpeed; + long MemSpeedx2; + long FastROMSpeed; uint32_t AutoSaveTimer; - bool SRAMModified; + bool SRAMModified; uint32_t NMITriggerPoint; - bool BRKTriggered; - bool TriedInterleavedMode2; + bool BRKTriggered; + bool TriedInterleavedMode2; uint32_t NMICycleCount; uint32_t IRQCycleCount; } SCPUState; -#define HBLANK_START_EVENT 0 -#define HBLANK_END_EVENT 1 -#define HTIMER_BEFORE_EVENT 2 -#define HTIMER_AFTER_EVENT 3 -#define NO_EVENT 4 +#define HBLANK_START_EVENT 0u +#define HBLANK_END_EVENT 1u +#define HTIMER_BEFORE_EVENT 2u +#define HTIMER_AFTER_EVENT 3u +#define NO_EVENT 4u typedef struct { /* CPU options */ - bool APUEnabled; - bool Shutdown; - uint8_t SoundSkipMethod; - long H_Max; - long HBlankStart; - long CyclesPercentage; - bool DisableIRQ; - bool Paused; - bool ForcedPause; - bool StopEmulation; - bool FrameAdvance; + bool APUEnabled; + bool Shutdown; + uint8_t SoundSkipMethod; + long H_Max; + long HBlankStart; + long CyclesPercentage; + bool DisableIRQ; + bool Paused; + bool ForcedPause; + bool StopEmulation; + bool FrameAdvance; /* Tracing options */ - bool TraceDMA; - bool TraceHDMA; - bool TraceVRAM; - bool TraceUnknownRegisters; - bool TraceDSP; + bool TraceDMA; + bool TraceHDMA; + bool TraceVRAM; + bool TraceUnknownRegisters; + bool TraceDSP; /* Joystick options */ - bool JoystickEnabled; + bool JoystickEnabled; /* ROM timing options (see also H_Max above) */ - bool ForcePAL; - bool ForceNTSC; - bool PAL; + bool ForcePAL; + bool ForceNTSC; + bool PAL; uint32_t FrameTimePAL; uint32_t FrameTimeNTSC; uint32_t FrameTime; uint32_t SkipFrames; /* ROM image options */ - bool ForceLoROM; - bool ForceHiROM; - bool ForceHeader; - bool ForceNoHeader; - bool ForceInterleaved; - bool ForceInterleaved2; - bool ForceNotInterleaved; + bool ForceLoROM; + bool ForceHiROM; + bool ForceHeader; + bool ForceNoHeader; + bool ForceInterleaved; + bool ForceInterleaved2; + bool ForceNotInterleaved; /* Peripherial options */ - bool ForceSuperFX; - bool ForceNoSuperFX; - bool ForceDSP1; - bool ForceNoDSP1; - bool ForceSA1; - bool ForceNoSA1; - bool ForceC4; - bool ForceNoC4; - bool ForceSDD1; - bool ForceNoSDD1; - bool MultiPlayer5; - bool Mouse; - bool SuperScope; - bool SRTC; + bool ForceSuperFX; + bool ForceNoSuperFX; + bool ForceDSP1; + bool ForceNoDSP1; + bool ForceSA1; + bool ForceNoSA1; + bool ForceC4; + bool ForceNoC4; + bool ForceSDD1; + bool ForceNoSDD1; + bool MultiPlayer5; + bool Mouse; + bool SuperScope; + bool SRTC; uint32_t ControllerOption; - bool ShutdownMaster; - bool MultiPlayer5Master; - bool SuperScopeMaster; - bool MouseMaster; - bool SuperFX; - bool DSP1Master; - bool SA1; - bool C4; - bool SDD1; - bool SPC7110; - bool SPC7110RTC; - bool OBC1; + bool ShutdownMaster; + bool MultiPlayer5Master; + bool SuperScopeMaster; + bool MouseMaster; + bool SuperFX; + bool DSP1Master; + bool SA1; + bool C4; + bool SDD1; + bool SPC7110; + bool SPC7110RTC; + bool OBC1; /* Sound options */ uint32_t SoundPlaybackRate; #ifdef USE_BLARGG_APU uint32_t SoundInputRate; #endif - bool TraceSoundDSP; - bool EightBitConsoleSound; // due to caching, this needs S9xSetEightBitConsoleSound() - int SoundBufferSize; - int SoundMixInterval; - bool SoundEnvelopeHeightReading; - bool DisableSoundEcho; - bool DisableMasterVolume; - bool SoundSync; - bool InterpolatedSound; - bool ThreadSound; - bool Mute; - bool NextAPUEnabled; + bool TraceSoundDSP; + bool EightBitConsoleSound; // due to caching, this needs S9xSetEightBitConsoleSound() + int SoundBufferSize; + int SoundMixInterval; + bool SoundEnvelopeHeightReading; + bool DisableSoundEcho; + bool DisableMasterVolume; + bool SoundSync; + bool InterpolatedSound; + bool ThreadSound; + bool Mute; + bool NextAPUEnabled; /* Graphics options */ - bool Transparency; - bool SupportHiRes; - bool Mode7Interpolate; + bool Transparency; + bool SupportHiRes; + bool Mode7Interpolate; /* SNES graphics options */ - bool BGLayering; - bool DisableGraphicWindows; - bool ForceTransparency; - bool ForceNoTransparency; - bool DisableHDMA; - bool DisplayFrameRate; - bool DisableRangeTimeOver; /* XXX: unused */ + bool BGLayering; + bool DisableGraphicWindows; + bool ForceTransparency; + bool ForceNoTransparency; + bool DisableHDMA; + bool DisplayFrameRate; + bool DisableRangeTimeOver; /* XXX: unused */ /* Others */ - bool ApplyCheats; + bool ApplyCheats; /* Fixes for individual games */ - bool StarfoxHack; - bool WinterGold; - bool BS; /* Japanese Satellite System games. */ - bool DaffyDuck; + bool StarfoxHack; + bool WinterGold; + bool BS; /* Japanese Satellite System games. */ + bool DaffyDuck; uint8_t APURAMInitialValue; - bool SampleCatchup; - bool JustifierMaster; - bool Justifier; - bool SecondJustifier; + bool SampleCatchup; + bool JustifierMaster; + bool Justifier; + bool SecondJustifier; int8_t SETA; - bool TakeScreenshot; + bool TakeScreenshot; int8_t StretchScreenshots; uint16_t DisplayColor; - int SoundDriver; - int AIDOShmId; - bool NoPatch; - bool ForceInterleaveGD24; + int SoundDriver; + int AIDOShmId; + bool NoPatch; + bool ForceInterleaveGD24; } SSettings; typedef struct @@ -270,7 +270,7 @@ typedef struct uint8_t SoundEnvelopeHeightReading2; uint8_t SRAMInitialValue; uint8_t Uniracers; - bool EchoOnlyOutput; + bool EchoOnlyOutput; } SSNESGameFixes; extern SSettings Settings; @@ -279,10 +279,8 @@ extern SSNESGameFixes SNESGameFixes; extern char String [513]; void S9xMessage(int type, int number, const char* message); -void S9xLoadSDD1Data(); void S9xSetPause(uint32_t mask); void S9xClearPause(uint32_t mask); #endif - diff --git a/source/soundux.c b/source/soundux.c index 9a6c304..280c9f9 100644 --- a/source/soundux.c +++ b/source/soundux.c @@ -15,20 +15,6 @@ if ((v) > 32767) \ (v) = 32767 -#define CLIP16_latch(v,l) \ - if ((v) < -32768) \ -{ (v) = -32768; (l)++; }\ - else \ - if ((v) > 32767) \ -{ (v) = 32767; (l)++; } - -#define CLIP24(v) \ - if ((v) < -8388608) \ - (v) = -8388608; \ - else \ - if ((v) > 8388607) \ -(v) = 8388607 - #define CLIP8(v) \ if ((v) < -128) \ (v) = -128; \ @@ -57,14 +43,10 @@ extern int32_t NoiseFreq [32]; static int32_t noise_gen; -#undef ABS -#define ABS(a) ((a) < 0 ? -(a) : (a)) - #define FIXED_POINT 0x10000UL #define FIXED_POINT_REMAINDER 0xffffUL #define FIXED_POINT_SHIFT 16 -#define VOL_DIV8 0x8000 #define VOL_DIV16 0x0080 #define ENVX_SHIFT 24 @@ -114,7 +96,7 @@ void S9xSetEnvRate(Channel* ch, uint32_t rate, int direction, int target) { ch->envx_target = target; - if (rate == ~0UL) + if (rate == ~((uint32_t) 0u)) { ch->direction = 0; rate = 0; @@ -338,33 +320,6 @@ int S9xGetEnvelopeHeight(int channel) return (0); } -#if 1 -void S9xSetSoundSample(int channel, uint16_t sample_number) -{ -} -#else -void S9xSetSoundSample(int channel, uint16_t sample_number) -{ - register Channel* ch = &SoundData.channels[channel]; - - if (ch->state != SOUND_SILENT && - sample_number != ch->sample_number) - { - int keep = ch->state; - ch->state = SOUND_SILENT; - ch->sample_number = sample_number; - ch->loop = false; - ch->needs_decode = true; - ch->last_block = false; - ch->previous [0] = ch->previous[1] = 0; - uint8_t* dir = S9xGetSampleAddress(sample_number); - ch->block_pointer = READ_WORD(dir); - ch->sample_pointer = 0; - ch->state = keep; - } -} -#endif - void S9xSetSoundFrequency(int channel, int hertz) { if (so.playback_rate) @@ -969,12 +924,6 @@ stereo_exit: } } -// For backwards compatibility with older port specific code -void S9xMixSamplesO(uint8_t* buffer, int sample_count, int byte_offset) -{ - S9xMixSamples(buffer + byte_offset, sample_count); -} - void S9xMixSamples(uint8_t* buffer, int sample_count) { int J; @@ -1306,5 +1255,4 @@ void S9xPlaySample(int channel) APU.DSP [APU_ADSR2 + (channel << 4)]); } - #endif diff --git a/source/soundux.h b/source/soundux.h index 45c177e..411e334 100644 --- a/source/soundux.h +++ b/source/soundux.h @@ -21,7 +21,6 @@ enum { MODE_NONE = SOUND_SILENT, MODE_ADSR, MODE_RELEASE = SOUND_RELEASE, #define ENVELOPE_SHIFT 7 #define MAX_VOLUME 127 #define VOLUME_SHIFT 7 -#define VOL_DIV 128 #define SOUND_DECODE_LENGTH 16 #define NUM_CHANNELS 8 @@ -33,11 +32,11 @@ enum { MODE_NONE = SOUND_SILENT, MODE_ADSR, MODE_RELEASE = SOUND_RELEASE, typedef struct { - int sound_fd; - int sound_switch; - int playback_rate; - int buffer_size; - bool encoded; + int sound_fd; + int sound_switch; + int playback_rate; + int buffer_size; + bool encoded; int32_t samples_mixed_so_far; int32_t play_position; uint32_t err_counter; @@ -46,63 +45,62 @@ typedef struct SoundStatus so; - typedef struct { - int state; - int type; - int16_t volume_left; - int16_t volume_right; + int state; + int type; + int16_t volume_left; + int16_t volume_right; uint32_t hertz; uint32_t frequency; uint32_t count; - bool loop; - int envx; - int16_t left_vol_level; - int16_t right_vol_level; - int16_t envx_target; + bool loop; + int envx; + int16_t left_vol_level; + int16_t right_vol_level; + int16_t envx_target; uint32_t env_error; uint32_t erate; - int direction; + int direction; uint32_t attack_rate; uint32_t decay_rate; uint32_t sustain_rate; uint32_t release_rate; uint32_t sustain_level; - int16_t sample; - int16_t decoded [16]; - int16_t previous16 [2]; + int16_t sample; + int16_t decoded [16]; + int16_t previous16 [2]; int16_t* block; uint16_t sample_number; - bool last_block; - bool needs_decode; + bool last_block; + bool needs_decode; uint32_t block_pointer; uint32_t sample_pointer; - int* echo_buf_ptr; - int mode; - int32_t envxx; - int16_t next_sample; - int32_t interpolate; - int32_t previous [2]; + int* echo_buf_ptr; + int mode; + int32_t envxx; + int16_t next_sample; + int32_t interpolate; + int32_t previous [2]; // Just incase they are needed in the future, for snapshot compatibility. uint32_t dummy [8]; } Channel; typedef struct { - int echo_enable; - int echo_feedback; /* range is -128 .. 127 */ - int echo_ptr; - int echo_buffer_size; - int echo_write_enabled; - int echo_channel_enable; - int pitch_mod; + int echo_enable; + int echo_feedback; /* range is -128 .. 127 */ + int echo_ptr; + int echo_buffer_size; + int echo_write_enabled; + int echo_channel_enable; + int pitch_mod; // Just incase they are needed in the future, for snapshot compatibility. uint32_t dummy [3]; - Channel channels [NUM_CHANNELS]; - int16_t master_volume [2]; /* range is -128 .. 127 */ - int16_t echo_volume [2]; /* range is -128 .. 127 */ - int noise_hertz; + Channel channels [NUM_CHANNELS]; + int16_t master_volume [2]; /* range is -128 .. 127 */ + int16_t echo_volume [2]; /* range is -128 .. 127 */ + int noise_hertz; } SSoundData; SSoundData SoundData; @@ -123,7 +121,6 @@ void S9xSetSoundKeyOff(int channel); void S9xSetSoundDecayMode(int channel); void S9xSetSoundAttachMode(int channel); void S9xSoundStartEnvelope(Channel*); -void S9xSetSoundSample(int channel, uint16_t sample_number); void S9xSetEchoFeedback(int echo_feedback); void S9xSetEchoEnable(uint8_t byte); void S9xSetEchoDelay(int byte); @@ -133,7 +130,6 @@ void S9xSetFrequencyModulationEnable(uint8_t byte); void S9xSetEnvelopeRate(int channel, uint32_t rate, int direction, int target); bool S9xSetSoundMode(int channel, int mode); -int S9xGetEnvelopeHeight(int channel); void S9xResetSound(bool full); void S9xFixSoundAfterSnapshotLoad(); void S9xPlaybackSoundSetting(int channel); @@ -142,7 +138,6 @@ void S9xFixEnvelope(int channel, uint8_t gain, uint8_t adsr1, uint8_t adsr2); void S9xStartSample(int channel); void S9xMixSamples(uint8_t* buffer, int sample_count); -void S9xMixSamplesO(uint8_t* buffer, int sample_count, int byte_offset); bool S9xOpenSoundDevice(int, bool, int); void S9xSetPlaybackRate(uint32_t rate); #endif diff --git a/source/spc700.h b/source/spc700.h index 1012f2d..f1d7046 100644 --- a/source/spc700.h +++ b/source/spc700.h @@ -60,15 +60,16 @@ typedef union uint8_t A, Y; } B; #endif + uint16_t W; } YAndA; typedef struct { - uint8_t P; - YAndA YA; - uint8_t X; - uint8_t S; + uint8_t P; + YAndA YA; + uint8_t X; + uint8_t S; uint16_t PC; } SAPURegisters; diff --git a/source/spc7110.c b/source/spc7110.c index acc4666..66bfecc 100644 --- a/source/spc7110.c +++ b/source/spc7110.c @@ -57,29 +57,27 @@ typedef struct SPC7110DecompressionLocationStruct //this maps an index.bin table to the decompression pack typedef struct SPC7110DecompressionIndexStruct { - int table; - bool is_file; + int table; + bool is_file; Data7110 location[256]; } Index7110; //this contains all the data for the decompression pack. typedef struct SPC7110DecompressionPackStructure { - uint8_t* binfiles[MAX_TABLES]; + uint8_t* binfiles[MAX_TABLES]; Index7110 tableEnts[MAX_TABLES]; - int last_table; - int idx; - uint8_t last_idx; - uint16_t last_offset; + int last_table; + int idx; + uint8_t last_idx; + uint16_t last_offset; } Pack7110; - -char pfold[9]; //hack variable for log naming (each game makes a different log) -Pack7110* decompack = - NULL; //decompression pack uses a fair chunk of RAM, so dynalloc it. -SPC7110Regs s7r; //SPC7110 registers, about 33KB -S7RTC rtc_f9; //FEOEZ (and Shounen Jump no SHou) RTC -void S9xUpdateRTC(); //S-RTC function hacked to work with the RTC +char pfold[9]; // Hack variable for log naming (each game makes a different log) +Pack7110* decompack = NULL; // Decompression pack uses a fair chunk of RAM, so dynalloc it. +SPC7110Regs s7r; // SPC7110 registers, about 33KB +S7RTC rtc_f9; // FEOEZ (and Shounen Jump no SHou) RTC +void S9xUpdateRTC(); // S-RTC function hacked to work with the RTC //Emulate power on state void S9xSpc7110Init() @@ -141,7 +139,6 @@ void S9xSpc7110Init() memset(s7r.bank50, 0x00, DECOMP_BUFFER_SIZE); } - //full cache decompression routine (memcpy) Method 1 void MovePackData() { @@ -224,8 +221,7 @@ void MovePackData() } } - -//this is similar to the last function, but it keeps the last 5 accessed files open, +// This is similar to the last function, but it keeps the last 5 accessed files open, // and reads the data directly. Method 2 void ReadPackData() { @@ -1390,12 +1386,10 @@ int S9xRTCDaysInMonth(int month, int year) return mdays; } - #define DAYTICKS (60*60*24) #define HOURTICKS (60*60) #define MINUTETICKS 60 - /**********************************************************************************************/ /* S9xUpdateRTC() */ /* Advance the RTC time */ @@ -1595,7 +1589,6 @@ bool Load7110Index(char* filename) return true; } - //Cache 1 load function void SPC7110Load(char* dirname) { @@ -1690,7 +1683,6 @@ void SPC7110Open(char* dirname) Copy7110 = &ReadPackData; CleanUp7110 = &Close7110Gfx; - } //Cache 3's load function @@ -1764,8 +1756,6 @@ void SPC7110Grab(char* dirname) Copy7110 = &GetPackData; CleanUp7110 = &Drop7110Gfx; - - } //Cache 1 clean up function @@ -1906,7 +1896,6 @@ void S9xSpc7110Reset() memset(s7r.bank50, 0x00, DECOMP_BUFFER_SIZE); } - //outputs a cumulative log for the game. //there's nothing really weird here, just //reading the old log, and writing a new one. @@ -2109,6 +2098,7 @@ void Do7110Logging() } } } + bool S9xSaveSPC7110RTC(S7RTC* rtc_f9) { FILE* fp; @@ -2167,4 +2157,3 @@ bool S9xLoadSPC7110RTC(S7RTC* rtc_f9) fclose(fp); return (true); } - diff --git a/source/spc7110.h b/source/spc7110.h index 0069c54..92fb1d3 100644 --- a/source/spc7110.h +++ b/source/spc7110.h @@ -35,10 +35,10 @@ void SPC7110Grab(char*); typedef struct SPC7110RTC { unsigned char reg[16]; - int16_t index; - uint8_t control; - bool init; - time_t last_used; + int16_t index; + uint8_t control; + bool init; + time_t last_used; } S7RTC; typedef struct SPC7110EmuVars @@ -88,20 +88,20 @@ typedef struct SPC7110EmuVars unsigned char reg4840; unsigned char reg4841; unsigned char reg4842; - uint8_t AlignBy; - uint8_t written; - uint8_t offset_add; - uint32_t DataRomOffset; - uint32_t DataRomSize; - uint32_t bank50Internal; - uint8_t bank50[DECOMP_BUFFER_SIZE]; - + uint8_t AlignBy; + uint8_t written; + uint8_t offset_add; + uint32_t DataRomOffset; + uint32_t DataRomSize; + uint32_t bank50Internal; + uint8_t bank50[DECOMP_BUFFER_SIZE]; } SPC7110Regs; + extern SPC7110Regs s7r; extern S7RTC rtc_f9; + // These are defined in spc7110.cpp bool S9xSaveSPC7110RTC(S7RTC* rtc_f9); bool S9xLoadSPC7110RTC(S7RTC* rtc_f9); #endif - diff --git a/source/srtc.h b/source/srtc.h index 00624cc..4306999 100644 --- a/source/srtc.h +++ b/source/srtc.h @@ -45,13 +45,12 @@ Index Description Range (nibble) typedef struct { - bool needs_init; - bool count_enable; // Does RTC mark time or is it frozen - uint8_t data [MAX_RTC_INDEX + 1]; - int8_t index; - uint8_t mode; - - time_t system_timestamp; // Of latest RTC load time + bool needs_init; + bool count_enable; // Does RTC mark time or is it frozen + uint8_t data [MAX_RTC_INDEX + 1]; + int8_t index; + uint8_t mode; + time_t system_timestamp; // Of latest RTC load time uint32_t pad; } SRTC_DATA; @@ -68,4 +67,3 @@ void S9xHardResetSRTC(); #define SRTC_SRAM_PAD (4 + 8 + 1 + MAX_RTC_INDEX) #endif // _srtc_h - diff --git a/source/tile.c b/source/tile.c index 72570cf..ba3a1a7 100644 --- a/source/tile.c +++ b/source/tile.c @@ -1009,4 +1009,3 @@ void DrawLargePixel16Sub1_2(uint32_t Tile, int32_t Offset, RENDER_TILE_LARGE(ScreenColors [pixel], LARGE_SUB_PIXEL1_2) } - diff --git a/source/tile.h b/source/tile.h index 7950546..427c975 100644 --- a/source/tile.h +++ b/source/tile.h @@ -250,4 +250,3 @@ break; \ } #endif - |