diff options
author | PikalaxALT <pikalaxalt@gmail.com> | 2019-06-26 08:13:38 -0400 |
---|---|---|
committer | PikalaxALT <pikalaxalt@gmail.com> | 2019-06-26 12:12:10 -0400 |
commit | fb06e4a3c94ae17b73df6d3aecf2d18213aa183e (patch) | |
tree | 550586e95b1d117f9552213d94861c2ff8c318d4 /include/gba | |
parent | 3f43523352b279fc4498ee4bfde2213504e3ece8 (diff) |
Modernize code
Can compile with arm-none-eabi-gcc 8.3.0
gbafix correctly handles ELF input
Diffstat (limited to 'include/gba')
-rw-r--r-- | include/gba/defines.h | 11 | ||||
-rw-r--r-- | include/gba/macro.h | 25 |
2 files changed, 36 insertions, 0 deletions
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 |