SNES: Reduced binary size by ~20KB

I refactored spc700.c:
- Replaced jump table by a switch. I'm aware that they're essentially the same thing (given our range), but the generated code is ~9KB less, so...
- Removed unnecessary inlining

Doesn't seem to have any performance impact, if anything it is marginally faster...

Possible improvements:
- Grouping identical instructions will reduce size further, but it might break the switch optimizations
- Finalizing the loop inside the function will certainly improve performance
This commit is contained in:
Alex Duchesne 2025-02-21 19:20:06 -05:00
parent 5fe002e10b
commit 66c194a9b0
3 changed files with 1468 additions and 2453 deletions

View File

@ -82,7 +82,6 @@ bool S9xInitSound(int32_t buffer_ms, int32_t lag_ms);
void S9xPrintAPUState(void);
extern uint8_t S9xAPUCycles [256]; /* Scaled cycle lengths */
extern const uint8_t S9xAPUCycleLengths [256]; /* Raw data. */
extern void (* const S9xApuOpcodes [256])(void);
#define APU_VOL_LEFT 0x00
#define APU_VOL_RIGHT 0x01

File diff suppressed because it is too large Load Diff

View File

@ -62,16 +62,15 @@ typedef struct
/* Needed by ILLUSION OF GAIA */
#define ONE_APU_CYCLE 21
void APUExecute(void);
#define APU_EXECUTE1() \
{ \
APU.Cycles += S9xAPUCycles [*IAPU.PC]; \
(*S9xApuOpcodes[*IAPU.PC]) (); \
}
APUExecute();
#define APU_EXECUTE() \
if (IAPU.APUExecuting) \
while (APU.Cycles <= CPU.Cycles) \
APU_EXECUTE1();
APUExecute();
#endif
#endif