diff --git a/source/arm9/hardware/lgy.c b/source/arm9/hardware/lgy.c index aa320e2..a19fec4 100644 --- a/source/arm9/hardware/lgy.c +++ b/source/arm9/hardware/lgy.c @@ -56,11 +56,15 @@ static void setupBiosOverlay(bool biosIntro) if(biosIntro) *((u8*)_arm7_stub_swi) = 0x26; } -static void setupSaveType(u16 saveType) +static u32 setupSaveType(u16 saveType) { REG_LGY_GBA_SAVE_TYPE = saveType; - static const u8 saveSizeLut[16] = {1, 1, 8, 8, 64, 64, 64, 64, 64, 64, 128, 128, 128, 128, 32, 0}; - g_saveSize = 1024u * saveSizeLut[saveType & 0xFu]; + // The last shift in the table is technically undefined behavior (C standard) + // but on ARM this will always result in 0. + // https://developer.arm.com/documentation/dui0489/h/arm-and-thumb-instructions/shift-operations + static const u8 saveSizeShiftLut[16] = {9, 9, 13, 13, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 15, 32}; + const u32 saveSize = 1u<