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 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+) (limited to 'include/gba') 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 -- 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/gba') 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 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/gba') 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