From fb06e4a3c94ae17b73df6d3aecf2d18213aa183e Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 26 Jun 2019 08:13:38 -0400 Subject: Modernize code Can compile with arm-none-eabi-gcc 8.3.0 gbafix correctly handles ELF input --- include/gba/defines.h | 11 +++++++++++ include/gba/macro.h | 25 +++++++++++++++++++++++++ include/global.h | 4 ++++ include/graphics.h | 3 --- include/player_pc.h | 2 ++ include/strings.h | 1 - 6 files changed, 42 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/gba/defines.h b/include/gba/defines.h index b68a2ad1e..b95946b15 100644 --- a/include/gba/defines.h +++ b/include/gba/defines.h @@ -6,9 +6,20 @@ #define TRUE 1 #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 +#define NOINLINE __attribute__((noinline)) +#else +#define NOINLINE +#endif + #define ALIGNED(n) __attribute__((aligned(n))) #define SOUND_INFO_PTR (*(struct SoundInfo **)0x3007FF0) diff --git a/include/gba/macro.h b/include/gba/macro.h index 3b35a1946..197febede 100644 --- a/include/gba/macro.h +++ b/include/gba/macro.h @@ -192,4 +192,29 @@ REG_IME = imeTemp; \ } \ +#if MODERN +#define FLOAT_UNS(x, bit) ({ \ + s##bit sx = x; \ + float fx = (float)sx; \ + if (sx < 0) fx += (1 << (bit - 1)) * 2.0f; \ + fx; \ +}) +#define DOUBLE_UNS(x, bit) ({ \ + s##bit sx = x; \ + double dx = (double)sx; \ + if (sx < 0) dx += (1 << (bit - 1)) * 2.0; \ + dx; \ +}) +#else +#define FLOAT_UNS(x, bit) ((float)(x)) +#define DOUBLE_UNS(x, bit) ((double)(x)) +#endif //MODERN + +#define FLOAT_U8(x) FLOAT_UNS(x, 8) +#define FLOAT_U16(x) FLOAT_UNS(x, 16) +#define FLOAT_U32(x) FLOAT_UNS(x, 32) +#define DOUBLE_U8(x) DOUBLE_UNS(x, 8) +#define DOUBLE_U16(x) DOUBLE_UNS(x, 16) +#define DOUBLE_U32(x) DOUBLE_UNS(x, 32) + #endif // GUARD_GBA_MACRO_H diff --git a/include/global.h b/include/global.h index 969680dd7..712a40866 100644 --- a/include/global.h +++ b/include/global.h @@ -62,6 +62,10 @@ #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) >= (b) ? (a) : (b)) +#if MODERN +#define abs(x) (((x) < 0) ? -(x) : (x)) +#endif + // Extracts the upper 16 bits of a 32-bit number #define HIHALF(n) (((n) & 0xFFFF0000) >> 16) diff --git a/include/graphics.h b/include/graphics.h index 43b014a9f..50bb5774e 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4005,9 +4005,6 @@ extern const u32 gBerryPalette_Starf[]; extern const u32 gBerryPic_Enigma[]; extern const u32 gBerryPalette_Enigma[]; -//credits -extern const u32 gCreditsCopyrightEnd_Gfx[]; - //pokenav extern const u8 gPokenavConditionMarker_Gfx[]; extern const u16 gPokenavConditionMarker_Pal[]; diff --git a/include/player_pc.h b/include/player_pc.h index 53bb25c6b..219c11440 100644 --- a/include/player_pc.h +++ b/include/player_pc.h @@ -1,6 +1,8 @@ #ifndef GUARD_PLAYER_PC_H #define GUARD_PLAYER_PC_H +#include "menu.h" + // local task defines #define PAGE_INDEX data[0] #define ITEMS_ABOVE_TOP data[1] diff --git a/include/strings.h b/include/strings.h index f30e82321..36a92281e 100644 --- a/include/strings.h +++ b/include/strings.h @@ -485,7 +485,6 @@ extern const u8 gText_CryOf[]; extern const u8 gText_SizeComparedTo[]; extern const u8 gText_PokedexRegistration[]; extern const u8 gText_UnkCtrlF908Clear01[]; -extern const u8 sText_TenDashes2[]; extern const u8 gText_5MarksPokemon[]; extern const u8 gText_UnkHeight[]; extern const u8 gText_UnkWeight[]; -- cgit v1.2.3 From b839c213073f99d73d03bb28f0fd350e13afba09 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 26 Jun 2019 16:23:00 -0400 Subject: Fix/suppress warnings when building with gcc-8 --- include/gba/defines.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'include') diff --git a/include/gba/defines.h b/include/gba/defines.h index b95946b15..9bd695aaa 100644 --- a/include/gba/defines.h +++ b/include/gba/defines.h @@ -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 -- cgit v1.2.3 From e92e9a184ccfa2aa3a226610d6c4e633e8082c10 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 28 Jun 2019 22:26:11 -0400 Subject: Support for non-dkA toolchains --- include/fieldmap.h | 4 ++-- include/global.h | 1 + include/link_rfu.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/fieldmap.h b/include/fieldmap.h index 2384ed46a..be5610a46 100644 --- a/include/fieldmap.h +++ b/include/fieldmap.h @@ -23,9 +23,9 @@ int GetMapBorderIdAt(int x, int y); int CanCameraMoveInDirection(int direction); u16 GetBehaviorByMetatileId(u16 metatileId); void GetCameraFocusCoords(u16 *x, u16 *y); -u8 MapGridGetMetatileLayerTypeAt(s32 x, s32 y); +u8 MapGridGetMetatileLayerTypeAt(int x, int y); u8 MapGridGetZCoordAt(int x, int y); -u8 CameraMove(s32 deltaX, s32 deltaY); +bool8 CameraMove(int deltaX, int deltaY); struct MapConnection *sub_8088950(u8 direction, int x, int y); bool8 sub_80889A8(u8 direction, int x, int y, struct MapConnection *connection); bool8 sub_8088A0C(int x, int src_width, int dest_width, int offset); diff --git a/include/global.h b/include/global.h index 712a40866..a76d6e4e3 100644 --- a/include/global.h +++ b/include/global.h @@ -2,6 +2,7 @@ #define GUARD_GLOBAL_H #include +#include #include "config.h" // we need to define config before gba headers as print stuff needs the functions nulled before defines. #include "gba/gba.h" #include "constants/global.h" diff --git a/include/link_rfu.h b/include/link_rfu.h index dc5b963d1..4bf106ec1 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -278,7 +278,7 @@ bool32 sub_8011B90(void); void sub_800FE50(u16 *a0); bool32 sub_800E540(u16 id, u8 *name); void sub_8011DE0(u32 arg0); -u8 sub_801100C(int a0); +u8 sub_801100C(s32 a0); void sub_800EF7C(void); bool8 sub_800DE7C(struct UnkLinkRfuStruct_02022B14 *buff1, u8 *buff2, u8 idx); bool8 sub_800DF34(struct UnkLinkRfuStruct_02022B14 *buff1, u8 *buff2, u8 idx); -- cgit v1.2.3 From f300f9e699c6f90c7f8da3a4e130a21f231073a0 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 30 Jun 2019 19:31:29 -0400 Subject: Revert FLOAT_U* and DOUBLE_U* macros --- include/gba/macro.h | 25 ------------------------- 1 file changed, 25 deletions(-) (limited to 'include') diff --git a/include/gba/macro.h b/include/gba/macro.h index 197febede..3b35a1946 100644 --- a/include/gba/macro.h +++ b/include/gba/macro.h @@ -192,29 +192,4 @@ REG_IME = imeTemp; \ } \ -#if MODERN -#define FLOAT_UNS(x, bit) ({ \ - s##bit sx = x; \ - float fx = (float)sx; \ - if (sx < 0) fx += (1 << (bit - 1)) * 2.0f; \ - fx; \ -}) -#define DOUBLE_UNS(x, bit) ({ \ - s##bit sx = x; \ - double dx = (double)sx; \ - if (sx < 0) dx += (1 << (bit - 1)) * 2.0; \ - dx; \ -}) -#else -#define FLOAT_UNS(x, bit) ((float)(x)) -#define DOUBLE_UNS(x, bit) ((double)(x)) -#endif //MODERN - -#define FLOAT_U8(x) FLOAT_UNS(x, 8) -#define FLOAT_U16(x) FLOAT_UNS(x, 16) -#define FLOAT_U32(x) FLOAT_UNS(x, 32) -#define DOUBLE_U8(x) DOUBLE_UNS(x, 8) -#define DOUBLE_U16(x) DOUBLE_UNS(x, 16) -#define DOUBLE_U32(x) DOUBLE_UNS(x, 32) - #endif // GUARD_GBA_MACRO_H -- cgit v1.2.3 From 20863ac85bcf047feeeba8295d0f9bcecef6f636 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 18 Jul 2019 20:46:00 -0400 Subject: Resolve compile warnings in modern --- include/pokenav.h | 4 ++-- include/text.h | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/pokenav.h b/include/pokenav.h index c840fd494..203d14015 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -4,7 +4,7 @@ #include "bg.h" #include "main.h" -typedef u32 (*LoopedTask)(int state); +typedef u32 (*LoopedTask)(s32 state); // Return values of LoopedTask functions. #define LT_INC_AND_PAUSE 0 @@ -111,7 +111,7 @@ void sub_81C7850(u32 a0); u32 sub_81C786C(void); void LoadLeftHeaderGfxForIndex(u32 arg0); void sub_81C7FA0(u32 arg0, bool32 arg1, bool32 arg2); -void sub_81C7AC0(int a0); +void sub_81C7AC0(s32 a0); bool32 sub_81C8010(void); void InitBgTemplates(const struct BgTemplate *templates, int count); bool32 IsPaletteFadeActive(void); diff --git a/include/text.h b/include/text.h index eba3d0c4e..d3ff663bb 100644 --- a/include/text.h +++ b/include/text.h @@ -166,7 +166,11 @@ struct TextPrinter void (*callback)(struct TextPrinterTemplate *, u16); // 0x10 - union __attribute__((packed)) { + union +#if !MODERN + __attribute__((packed)) +#endif + { struct TextPrinterSubStruct sub; u8 fields[7]; } subUnion; -- cgit v1.2.3