diff options
author | Michael Panzlaff <michael.panzlaff@fau.de> | 2020-05-09 14:49:51 +0200 |
---|---|---|
committer | Michael Panzlaff <michael.panzlaff@fau.de> | 2020-07-05 18:09:59 +0200 |
commit | 3264cf697f5fe996c2a79c6c34181c186fe2f96e (patch) | |
tree | 919e94607188da2a6e561f41dfba39e3a7558b24 /src/slot_machine.c | |
parent | 46f4a4bbf7239743c333cd32d30b74a7b3176acc (diff) |
fix aggressive loop optimizations
Previously, aggressive loop optimizations with a new compiler were not
possible due to undefined behaviour at end of arrays.
A macro "UBFIX" is added to allow ifdefs for fixes which resolve
undefined behavior. For example newer GCC versions will detect various
bugs in the original game code and will otherwise not compile with -Werror.
Diffstat (limited to 'src/slot_machine.c')
-rw-r--r-- | src/slot_machine.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/slot_machine.c b/src/slot_machine.c index 9e94d11f0..d1cb05b18 100644 --- a/src/slot_machine.c +++ b/src/slot_machine.c @@ -384,7 +384,7 @@ static const u16 gSlotPayouts[]; static const u8 *const gUnknown_083EDCE4; static const u8 *const gUnknown_083EDCDC; static const u32 gReelTimeGfx[]; -static const struct SpriteSheet gSlotMachineSpriteSheets[]; +static const struct SpriteSheet gSlotMachineSpriteSheets[22]; static const struct SpritePalette gSlotMachineSpritePalettes[]; static const u16 *const gUnknown_083EDE20; static const s16 gInitialReelPositions[][2]; @@ -4171,8 +4171,8 @@ static void sub_81063C0(void) LZDecompressWram(gSlotMachineReelTime_Gfx, sUnknown_0203AAD4); sUnknown_0203AAD8 = Alloc(0x3600); LZDecompressWram(gReelTimeGfx, sUnknown_0203AAD8); - sUnknown_0203AB30 = AllocZeroed(sizeof(struct SpriteSheet) * 22); - for (i = 0; i < 22; i++) + sUnknown_0203AB30 = AllocZeroed(sizeof(struct SpriteSheet) * ARRAY_COUNT(gSlotMachineSpriteSheets)); + for (i = 0; i < ARRAY_COUNT(gSlotMachineSpriteSheets); i++) { sUnknown_0203AB30[i].data = gSlotMachineSpriteSheets[i].data; sUnknown_0203AB30[i].size = gSlotMachineSpriteSheets[i].size; @@ -6708,7 +6708,7 @@ static const struct SubspriteTable *const gUnknown_083EDBC4[] = NULL }; -static const struct SpriteSheet gSlotMachineSpriteSheets[] = +static const struct SpriteSheet gSlotMachineSpriteSheets[22] = { { .data = gSlotMachineReelSymbol1Tiles, .size = 0x200, .tag = 0 }, { .data = gSlotMachineReelSymbol2Tiles, .size = 0x200, .tag = 1 }, @@ -6727,15 +6727,12 @@ static const struct SpriteSheet gSlotMachineSpriteSheets[] = { .data = gSlotMachineNumber7Tiles, .size = 0x40, .tag = 14 }, { .data = gSlotMachineNumber8Tiles, .size = 0x40, .tag = 15 }, { .data = gSlotMachineNumber9Tiles, .size = 0x40, .tag = 16 }, -}; - -static const u8 sUnused1[][8] = -{ - {0, 0, 0, 0, 0, 2, 18}, - {0, 0, 0, 0, 0, 2, 19}, - {0, 0, 0, 0, 0, 3, 20}, - {0, 0, 0, 0, 0, 3, 21}, - {0, 0, 0, 0, 0, 0, 0} + // the data for these sheets is determined at runtime + { .data = NULL, .size = 0x200, .tag = 18 }, + { .data = NULL, .size = 0x200, .tag = 19 }, + { .data = NULL, .size = 0x300, .tag = 20 }, + { .data = NULL, .size = 0x300, .tag = 21 }, + {}, }; static const u8 *const gUnknown_083EDCDC = gUnknown_08DD19F8; |