Merge pull request #445 from Kurausukun/ubfix

Port UBFIX Macro and Some Usages from Emerald
This commit is contained in:
GriffinR authored and GitHub committed 2021-07-03 17:25:05 -04:00
commit 585d92f298
13 files changed
+76 -14

No files matched your search

+3
View File
@@ -41,6 +41,9 @@
#ifndef BUGFIX
#define BUGFIX
#endif // BUGFIX
#ifndef UBFIX
#define UBFIX
#endif // UBFIX
#endif // MODERN
#endif // GUARD_CONFIG_H
+8
View File
@@ -73,6 +73,14 @@
#define abs(x) (((x) < 0) ? -(x) : (x))
#endif
// Used in cases where division by 0 can occur in the retail version.
// Avoids invalid opcodes on some emulators, and the otherwise UB.
#ifdef UBFIX
#define SAFE_DIV(a, b) ((b) ? (a) / (b) : 0)
#else
#define SAFE_DIV(a, b) ((a) / (b))
#endif
// There are many quirks in the source code which have overarching behavioral differences from
// a number of other files. For example, diploma.c seems to declare rodata before each use while
// other files declare out of order and must be at the beginning. There are also a number of