Fix/suppress warnings when building with gcc-8

This commit is contained in:
PikalaxALT 2019-06-26 16:23:00 -04:00
parent fb06e4a3c9
commit b839c21307
37 changed files with 114 additions and 111 deletions

View File

@ -41,7 +41,7 @@ ROM := pokeemerald.gba
OBJ_DIR := build/emerald
else
CC1 := $(shell $(PREFIX)gcc --print-prog-name=cc1)
override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -quiet -fno-toplevel-reorder -Wno-aggressive-loop-optimizations
override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -quiet -fno-toplevel-reorder -Wno-aggressive-loop-optimizations -Wno-pointer-to-int-cast
ROM := pokeemerald_modern.gba
OBJ_DIR := build/modern
endif

View File

@ -7,11 +7,7 @@
#define FALSE 0
#define BSS_DATA __attribute__((section(".bss")))
#if MODERN
#define IWRAM_DATA
#else
#define IWRAM_DATA __attribute__((section("iwram_data")))
#endif
#define EWRAM_DATA __attribute__((section("ewram_data")))
#if MODERN

View File

@ -16,7 +16,7 @@
#include "constants/moves.h"
// IWRAM bss
static IWRAM_DATA bool8 sPerformedRentalSwap;
static bool8 sPerformedRentalSwap;
// This file's functions.
static void InitFactoryChallenge(void);

View File

@ -227,9 +227,9 @@ static EWRAM_DATA u8 *sSwapMenuTilemapBuffer = NULL;
static EWRAM_DATA u8 *sSwapMonCardBgTilemapBuffer = NULL;
// IWRAM bss
static IWRAM_DATA struct FactorySelectMonsStruct *sFactorySelectScreen;
static IWRAM_DATA void (*sSwap_CurrentTableFunc)(u8 taskId);
static IWRAM_DATA struct FactorySwapMonsStruct *sFactorySwapScreen;
static struct FactorySelectMonsStruct *sFactorySelectScreen;
static void (*sSwap_CurrentTableFunc)(u8 taskId);
static struct FactorySwapMonsStruct *sFactorySwapScreen;
// IWRAM common
u8 (*gUnknown_030062E8)(void);

View File

@ -53,11 +53,11 @@ struct PikeWildMon
};
// IWRAM bss
static IWRAM_DATA u8 sRoomType;
static IWRAM_DATA u8 sStatusMon;
static IWRAM_DATA bool8 sUnknown_0300128E;
static IWRAM_DATA u32 sStatusFlags;
static IWRAM_DATA u8 sNpcId;
static u8 sRoomType;
static u8 sStatusMon;
static bool8 sUnknown_0300128E;
static u32 sStatusFlags;
static u8 sNpcId;
// This file's functions.
static void SetRoomType(void);

View File

@ -44,7 +44,7 @@ static void sub_81BA040(void);
static void sub_81B9EC0(void);
// IWRAM bss
static IWRAM_DATA u16 sRandMonSetId;
static u16 sRandMonSetId;
// const rom data
void static (*const gUnknown_086160B4[])(void) =

View File

@ -262,10 +262,10 @@ static bool8 sub_814842C(struct Sprite *sprite);
static bool8 sub_8148458(struct Sprite *sprite);
// iwram bss vars
IWRAM_DATA static s16 sUnusedRectangularSpiralVar;
IWRAM_DATA static u8 sTestingTransitionId;
IWRAM_DATA static u8 sTestingTransitionState;
IWRAM_DATA static struct StructRectangularSpiral sRectangularSpiralTransition[4];
static s16 sUnusedRectangularSpiralVar;
static u8 sTestingTransitionId;
static u8 sTestingTransitionState;
static struct StructRectangularSpiral sRectangularSpiralTransition[4];
// ewram vars
EWRAM_DATA static struct TransitionData *sTransitionStructPtr = NULL;

View File

@ -194,10 +194,10 @@ EWRAM_DATA static s32 sUnknown_020322BC[5] = {0};
EWRAM_DATA static u32 sUnknown_020322D0 = 0;
// IWRAM bss
IWRAM_DATA static s16 sUnknown_03000DE8[8];
IWRAM_DATA static s16 sUnknown_03000DF8[6];
IWRAM_DATA static s16 sUnknown_03000E04;
IWRAM_DATA static s16 sUnknown_03000E06;
static s16 sUnknown_03000DE8[8];
static s16 sUnknown_03000DF8[6];
static s16 sUnknown_03000E04;
static s16 sUnknown_03000E06;
// IWRAM common
u8 gInGameOpponentsNo;

View File

@ -37,9 +37,9 @@ struct BgConfig2
s32 bg_y;
};
static IWRAM_DATA struct BgControl sGpuBgConfigs;
static IWRAM_DATA struct BgConfig2 sGpuBgConfigs2[4];
static IWRAM_DATA u32 sDmaBusyBitfield[4];
static struct BgControl sGpuBgConfigs;
static struct BgConfig2 sGpuBgConfigs2[4];
static u32 sDmaBusyBitfield[4];
u32 gUnneededFireRedVariable;

View File

@ -73,7 +73,7 @@ static void CreateRandomEggShardSprite(void);
static void CreateEggShardSprite(u8 x, u8 y, s16 data1, s16 data2, s16 data3, u8 spriteAnimIndex);
// IWRAM bss
static IWRAM_DATA struct EggHatchData *sEggHatchData;
static struct EggHatchData *sEggHatchData;
// rom data
static const u16 sEggPalette[] = INCBIN_U16("graphics/pokemon/egg/normal.gbapal");

View File

@ -36,11 +36,11 @@ static void DrawMetatile(s32 a, u16 *b, u16 c);
static void CameraPanningCB_PanAhead(void);
// IWRAM bss vars
static IWRAM_DATA struct FieldCameraOffset sFieldCameraOffset;
static IWRAM_DATA s16 sHorizontalCameraPan;
static IWRAM_DATA s16 sVerticalCameraPan;
static IWRAM_DATA u8 gUnknown_03000E2C;
static IWRAM_DATA void (*sFieldCameraPanningCallback)(void);
static struct FieldCameraOffset sFieldCameraOffset;
static s16 sHorizontalCameraPan;
static s16 sVerticalCameraPan;
static u8 gUnknown_03000E2C;
static void (*sFieldCameraPanningCallback)(void);
struct CameraObject gFieldCamera;
u16 gTotalCameraPixelOffsetY;

View File

@ -232,7 +232,7 @@ static void Fldeff_MoveDeoxysRock_Step(u8 taskId);
// Static RAM declarations
static IWRAM_DATA u8 sActiveList[32];
static u8 sActiveList[32];
// External declarations
extern struct CompressedSpritePalette gMonPaletteTable[]; // GF made a mistake and did not extern it as const.

View File

@ -68,7 +68,7 @@ static u8 None_Finish(void);
EWRAM_DATA struct Weather gWeather = {0};
EWRAM_DATA static u8 sFieldEffectPaletteGammaTypes[32] = {0};
IWRAM_DATA static const u8 *sPaletteGammaTypes;
static const u8 *sPaletteGammaTypes;
// The drought weather effect uses a precalculated color lookup table. Presumably this
// is because the underlying color shift calculation is slow.

View File

@ -59,11 +59,11 @@ static void CutGrassSpriteCallbackEnd(struct Sprite *);
static void HandleLongGrassOnHyper(u8, s16, s16);
// IWRAM variables
static IWRAM_DATA u8 sCutSquareSide;
static IWRAM_DATA u8 sTileCountFromPlayer_X;
static IWRAM_DATA u8 sTileCountFromPlayer_Y;
static IWRAM_DATA u32 sUnused;
static IWRAM_DATA bool8 sHyperCutTiles[CUT_HYPER_AREA];
static u8 sCutSquareSide;
static u8 sTileCountFromPlayer_X;
static u8 sTileCountFromPlayer_Y;
static u32 sUnused;
static bool8 sHyperCutTiles[CUT_HYPER_AREA];
// EWRAM variables
static EWRAM_DATA u8 *sCutGrassSpriteArrayPtr = NULL;

View File

@ -42,10 +42,10 @@ EWRAM_DATA struct LoadedSaveData gLoadedSaveData = {0};
EWRAM_DATA u32 gLastEncryptionKey = 0;
// IWRAM common
IWRAM_DATA bool32 gFlashMemoryPresent;
IWRAM_DATA struct SaveBlock1 *gSaveBlock1Ptr;
IWRAM_DATA struct SaveBlock2 *gSaveBlock2Ptr;
IWRAM_DATA struct PokemonStorage *gPokemonStoragePtr;
bool32 gFlashMemoryPresent;
struct SaveBlock1 *gSaveBlock1Ptr;
struct SaveBlock2 *gSaveBlock2Ptr;
struct PokemonStorage *gPokemonStoragePtr;
// code
void CheckForFlashMemory(void)

View File

@ -85,7 +85,14 @@ void EnableVCountIntrAtLine150(void);
void AgbMain()
{
RegisterRamReset(MODERN ? RESET_ALL & ~RESET_IWRAM : RESET_ALL);
#if MODERN
// Modern compilers are liberal with the stack on entry to this function,
// so RegisterRamReset may crash if it resets IWRAM.
RegisterRamReset(RESET_ALL & ~RESET_IWRAM);
DmaFill32(3, 0, IWRAM_START, 0x7E00);
#else
RegisterRamReset(RESET_ALL);
#endif //MODERN
*(vu16 *)BG_PLTT = 0x7FFF;
InitGpuRegManager();
REG_WAITCNT = WAITCNT_PREFETCH_ENABLE | WAITCNT_WS0_S_1 | WAITCNT_WS0_N_3;

View File

@ -176,7 +176,7 @@
static EWRAM_DATA u8 gUnknown_02022D04 = 0;
static EWRAM_DATA u16 sCurrItemAndOptionMenuCheck = 0;
static IWRAM_DATA u8 sBirchSpeechMainTaskId;
static u8 sBirchSpeechMainTaskId;
// Static ROM declarations

View File

@ -27,7 +27,7 @@ EWRAM_DATA static struct YesNoFuncTable gUnknown_0203A138 = {0};
EWRAM_DATA static u8 gUnknown_0203A140 = 0;
// IWRAM bss vars
IWRAM_DATA static TaskFunc gUnknown_0300117C;
static TaskFunc gUnknown_0300117C;
// const rom data
static const struct OamData sOamData_859F4E8 =

View File

@ -258,7 +258,7 @@ EWRAM_DATA static struct Struct203CF10 *sUnknown_0203CF10 = NULL;
EWRAM_DATA static struct BgRegOffsets *sBgShakeOffsets = NULL;
EWRAM_DATA struct MirageTowerPulseBlend *sMirageTowerPulseBlend = NULL;
IWRAM_DATA static u16 gUnknown_030012A8[8];
static u16 gUnknown_030012A8[8];
bool8 IsMirageTowerVisible(void)
{

View File

@ -1,7 +1,7 @@
#include "gba/gba.h"
#include "multiboot.h"
IWRAM_DATA static u16 MultiBoot_required_data[MULTIBOOT_NCHILD];
static u16 MultiBoot_required_data[MULTIBOOT_NCHILD];
static int MultiBootSend(struct MultiBootParam *mp, u16 data);
static int MultiBootHandShake(struct MultiBootParam *mp);

View File

@ -186,15 +186,15 @@ static u8 GetAdjustedInitialDirection(struct InitialPlayerAvatarState *playerStr
static u16 GetCenterScreenMetatileBehavior(void);
// IWRAM bss vars
IWRAM_DATA static void *sUnusedOverworldCallback;
IWRAM_DATA static u8 sPlayerTradingStates[4];
static void *sUnusedOverworldCallback;
static u8 sPlayerTradingStates[4];
// This callback is called with a player's key code. It then returns an
// adjusted key code, effectively intercepting the input before anything
// can process it.
IWRAM_DATA static u16 (*sPlayerKeyInterceptCallback)(u32);
IWRAM_DATA static bool8 sUnknown_03000E18;
IWRAM_DATA static u8 sRfuKeepAliveTimer;
IWRAM_DATA static u32 sUnusedVar;
static u16 (*sPlayerKeyInterceptCallback)(u32);
static bool8 sUnknown_03000E18;
static u8 sRfuKeepAliveTimer;
static u32 sUnusedVar;
// IWRAM common
u16 *gBGTilemapBuffers1;

View File

@ -1596,8 +1596,8 @@ static void InitPartyMenu(u8 a, u8 b, u8 c, u8 d, u8 messageId, TaskFunc task, M
gUnknown_0203CEC4->task = task;
gUnknown_0203CEC4->exitCallback = NULL;
gUnknown_0203CEC4->unk8_1 = 0;
gUnknown_0203CEC4->unk8_2 = 0xFF;
gUnknown_0203CEC4->unk9_0 = 0xFF;
gUnknown_0203CEC4->unk8_2 = 0x7F;
gUnknown_0203CEC4->unk9_0 = 0x7F;
if (a == 4)
gUnknown_0203CEC4->unk8_0 = TRUE;

View File

@ -763,11 +763,11 @@ static void sub_813D6B4(void)
static void CreateAreaMarkerSprites(void)
{
u8 spriteId;
static IWRAM_DATA s16 x;
static IWRAM_DATA s16 y;
static IWRAM_DATA s16 i;
static IWRAM_DATA s16 mapSecId;
static IWRAM_DATA s16 numSprites;
static s16 x;
static s16 y;
static s16 i;
static s16 mapSecId;
static s16 numSprites;
LoadSpriteSheet(&sAreaMarkerSpriteSheet);
LoadSpritePalette(&sAreaMarkerSpritePalette);

View File

@ -177,9 +177,9 @@ static void SpriteCB_SetDummyOnAnimEnd(struct Sprite *sprite);
#define STRUCT_COUNT 4
// IWRAM bss
static IWRAM_DATA struct UnkAnimStruct sUnknown_03001240[STRUCT_COUNT];
static IWRAM_DATA u8 sUnknown_03001270;
static IWRAM_DATA bool32 sUnknown_03001274;
static struct UnkAnimStruct sUnknown_03001240[STRUCT_COUNT];
static u8 sUnknown_03001270;
static bool32 sUnknown_03001274;
// const rom data
static const u8 sSpeciesToBackAnimSet[] =

View File

@ -443,7 +443,7 @@ enum
#define TAG_TILE_1 0x1
// IWRAM bss
IWRAM_DATA static u32 gUnknown_03000F78[98];
static u32 gUnknown_03000F78[98];
// EWRAM DATA
EWRAM_DATA static u8 sPreviousBoxOption = 0;

View File

@ -8,8 +8,8 @@ EWRAM_DATA static u8 sUnknown = 0;
EWRAM_DATA static u32 sRandCount = 0;
// IWRAM common
IWRAM_DATA u32 gRngValue;
IWRAM_DATA u32 gRng2Value;
u32 gRngValue;
u32 gRng2Value;
u16 Random(void)
{

View File

@ -82,21 +82,21 @@ union PlayerRecords
// Static RAM declarations
static IWRAM_DATA bool8 gUnknown_03001130;
static IWRAM_DATA struct SecretBase *sSecretBasesSave;
static IWRAM_DATA TVShow *sTvShowsSave;
static IWRAM_DATA PokeNews *sPokeNewsSave;
static IWRAM_DATA OldMan *sOldManSave;
static IWRAM_DATA struct EasyChatPair *sEasyChatPairsSave;
static IWRAM_DATA struct RecordMixingDayCareMail *gUnknown_03001148;
static IWRAM_DATA void *sBattleTowerSave;
static IWRAM_DATA LilycoveLady *sLilycoveLadySave;
static IWRAM_DATA void *sApprenticesSave;
static IWRAM_DATA void *sBattleTowerSave_Duplicate;
static IWRAM_DATA u32 sRecordStructSize;
static IWRAM_DATA u8 gUnknown_03001160;
static IWRAM_DATA u32 filler_03001164;
static IWRAM_DATA struct PlayerHallRecords *gUnknown_03001168[3];
static bool8 gUnknown_03001130;
static struct SecretBase *sSecretBasesSave;
static TVShow *sTvShowsSave;
static PokeNews *sPokeNewsSave;
static OldMan *sOldManSave;
static struct EasyChatPair *sEasyChatPairsSave;
static struct RecordMixingDayCareMail *gUnknown_03001148;
static void *sBattleTowerSave;
static LilycoveLady *sLilycoveLadySave;
static void *sApprenticesSave;
static void *sBattleTowerSave_Duplicate;
static u32 sRecordStructSize;
static u8 gUnknown_03001160;
static u32 filler_03001164;
static struct PlayerHallRecords *gUnknown_03001168[3];
static EWRAM_DATA struct RecordMixingDayCareMail gUnknown_02039F9C = {0};
static EWRAM_DATA union PlayerRecords *sReceivedRecords = NULL;

View File

@ -100,8 +100,8 @@ EWRAM_DATA static u8 sApprenticeId = 0;
EWRAM_DATA static u16 sEasyChatSpeech[6] = {0};
EWRAM_DATA static u8 sBattleOutcome = 0;
IWRAM_DATA static u8 sRecordMixFriendLanguage;
IWRAM_DATA static u8 sApprenticeLanguage;
static u8 sRecordMixFriendLanguage;
static u8 sApprenticeLanguage;
// this file's functions
static u8 sub_8185278(u8 *arg0, u8 *arg1, u8 *arg2);

View File

@ -14,7 +14,7 @@ void sub_81700F8(void)
imeBackup = REG_IME;
REG_IME = 0;
RegisterRamReset(0x00000001);
RegisterRamReset(RESET_EWRAM);
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_FORCED_BLANK);
REG_IME = imeBackup;
gMain.inBattle = FALSE;

View File

@ -43,9 +43,9 @@ static bool32 SharesPalWithAnyActive(u32 id);
static void sub_8035648(void);
// iwram
static IWRAM_DATA s32 gUnknown_03000DD4;
static IWRAM_DATA s32 gUnknown_03000DD8;
static IWRAM_DATA s32 gUnknown_03000DDC;
static s32 gUnknown_03000DD4;
static s32 gUnknown_03000DD8;
static s32 gUnknown_03000DDC;
// ewram
static EWRAM_DATA struct UnkStruct1 *gUnknown_02022E10 = {0};

View File

@ -408,8 +408,8 @@ void UpdatePulseBlend(struct PulseBlend *pulseBlend)
}
}
break;
case 2: // Flip back and forth
// This code is never reached
case (MODERN ? -2 : 2): // Flip back and forth
// This code is never reached in vanilla
if (pulseBlendPalette->fadeDirection)
pulseBlendPalette->blendCoeff = 0;
else

View File

@ -4,10 +4,10 @@
#include "text.h"
// iwram bss
IWRAM_DATA static u16 sErrorStatus;
IWRAM_DATA static struct SiiRtcInfo sRtc;
IWRAM_DATA static u8 sProbeResult;
IWRAM_DATA static u16 sSavedIme;
static u16 sErrorStatus;
static struct SiiRtcInfo sRtc;
static u8 sProbeResult;
static u16 sSavedIme;
// iwram common
struct Time gLocalTime;

View File

@ -10,12 +10,12 @@
extern const u8* gUnknown_020375C0;
// ewram bss
IWRAM_DATA static u8 sScriptContext1Status;
IWRAM_DATA static u32 sUnusedVariable1;
IWRAM_DATA static struct ScriptContext sScriptContext1;
IWRAM_DATA static u32 sUnusedVariable2;
IWRAM_DATA static struct ScriptContext sScriptContext2;
IWRAM_DATA static bool8 sScriptContext2Enabled;
static u8 sScriptContext1Status;
static u32 sUnusedVariable1;
static struct ScriptContext sScriptContext1;
static u32 sUnusedVariable2;
static struct ScriptContext sScriptContext2;
static bool8 sScriptContext2Enabled;
extern ScrCmdFunc gScriptCmdTable[];
extern ScrCmdFunc gScriptCmdTableEnd[];

View File

@ -350,7 +350,7 @@ static EWRAM_DATA struct SpriteSheet *sUnknown_0203AB30 = NULL;
static EWRAM_DATA struct SlotMachineEwramStruct *sSlotMachine = NULL;
// IWRAM bss
static IWRAM_DATA struct SpriteFrameImage *gUnknown_03001188[26];
static struct SpriteFrameImage *gUnknown_03001188[26];
// Const rom data.
extern const struct UnkStruct1 *const gUnknown_083ED048[];

View File

@ -19,11 +19,11 @@ EWRAM_DATA struct MusicPlayerInfo* gMPlay_PokemonCry = NULL;
EWRAM_DATA u8 gPokemonCryBGMDuckingCounter = 0;
// iwram bss
IWRAM_DATA static u16 sCurrentMapMusic;
IWRAM_DATA static u16 sNextMapMusic;
IWRAM_DATA static u8 sMapMusicState;
IWRAM_DATA static u8 sMapMusicFadeInSpeed;
IWRAM_DATA static u16 sFanfareCounter;
static u16 sCurrentMapMusic;
static u16 sNextMapMusic;
static u8 sMapMusicState;
static u8 sMapMusicFadeInSpeed;
static u16 sFanfareCounter;
// iwram common
bool8 gDisableMusic;

View File

@ -285,10 +285,10 @@ static const struct OamDimensions sOamDimensions[3][4] =
};
// iwram bss
IWRAM_DATA static u16 sSpriteTileRangeTags[MAX_SPRITES];
IWRAM_DATA static u16 sSpriteTileRanges[MAX_SPRITES * 2];
IWRAM_DATA static struct AffineAnimState sAffineAnimStates[OAM_MATRIX_COUNT];
IWRAM_DATA static u16 sSpritePaletteTags[16];
static u16 sSpriteTileRangeTags[MAX_SPRITES];
static u16 sSpriteTileRanges[MAX_SPRITES * 2];
static struct AffineAnimState sAffineAnimStates[OAM_MATRIX_COUNT];
static u16 sSpritePaletteTags[16];
// iwram common
u32 gOamMatrixAllocBitmap;

View File

@ -51,7 +51,7 @@ void sub_81346DC(struct Sprite *sprite);
void sub_813473C(struct Sprite *sprite);
void StarterPokemonSpriteCallback(struct Sprite *sprite);
static IWRAM_DATA u16 sStarterChooseWindowId;
static u16 sStarterChooseWindowId;
// .rodata
const u16 gBirchBagGrassPal[][16] =