diff options
author | Marcus Huderle <huderlem@gmail.com> | 2018-01-11 18:25:42 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-11 18:25:42 -0800 |
commit | d1630d481a0ff611fda2d70a100eed5046982cec (patch) | |
tree | e4de58bbf80fca6a78ea1db48a8f1ab36a81c789 /include | |
parent | 73d3a21c2d0a0352cd314e7211fac316cd03b351 (diff) | |
parent | e1801885a0619724860cb322ba1cb8dba2b2c0f3 (diff) |
Merge pull request #155 from ProjectRevoTPP/assert
add assert support to pokeemerald.
Diffstat (limited to 'include')
-rw-r--r-- | include/config.h | 17 | ||||
-rw-r--r-- | include/gba/gba.h | 1 | ||||
-rwxr-xr-x | include/gba/isagbprint.h | 50 | ||||
-rw-r--r-- | include/global.h | 2 |
4 files changed, 69 insertions, 1 deletions
diff --git a/include/config.h b/include/config.h index 162af3143..318ed39d8 100644 --- a/include/config.h +++ b/include/config.h @@ -1,6 +1,23 @@ #ifndef GUARD_CONFIG_H #define GUARD_CONFIG_H +// In the Generation 3 games, Asserts were used in various debug builds. +// Ruby/Sapphire and Emerald do not have these asserts while Fire Red +// still has them in the ROM. This is because the developers forgot +// to define NDEBUG before release, however this has been changed as +// Ruby's actual debug build does not use the AGBPrint features. +#define NDEBUG + +// To enable print debugging, comment out "#define NDEBUG". This allows +// the various AGBPrint functions to be used. (See include/gba/isagbprint.h). +// Some emulators support a debug console window: uncomment NoCashGBAPrint() +// and NoCashGBAPrintf() in libisagbprn.c to use no$gba's own proprietary +// printing system. Use NoCashGBAPrint() and NoCashGBAPrintf() like you +// would normally use AGBPrint() and AGBPrintf(). + +// NOTE: Don't try to enable assert right now as many pointers +// still exist in defines and WILL likely result in a broken ROM. + #define ENGLISH #ifdef ENGLISH diff --git a/include/gba/gba.h b/include/gba/gba.h index 42ae3cdde..349344031 100644 --- a/include/gba/gba.h +++ b/include/gba/gba.h @@ -7,5 +7,6 @@ #include "gba/multiboot.h" #include "gba/syscall.h" #include "gba/macro.h" +#include "gba/isagbprint.h" #endif // GUARD_GBA_GBA_H diff --git a/include/gba/isagbprint.h b/include/gba/isagbprint.h new file mode 100755 index 000000000..c5eb456c3 --- /dev/null +++ b/include/gba/isagbprint.h @@ -0,0 +1,50 @@ +#ifndef GUARD_GBA_ISAGBPRINT_H +#define GUARD_GBA_ISAGBPRINT_H + +#ifdef NDEBUG +#define AGBPrintInit() +#define AGBPutc(cChr) +#define AGBPrint(pBuf) +#define AGBPrintf(pBuf, ...) +#define AGBPrintFlush1Block() +#define AGBPrintFlush() +#define AGBAssert(pFile, nLine, pExpression, nStopProgram) +#else +void AGBPrintInit(void); +void AGBPutc(const char cChr); +void AGBPrint(const char *pBuf); +void AGBPrintf(const char *pBuf, ...); +void AGBPrintFlush1Block(void); +void AGBPrintFlush(void); +void AGBAssert(const char *pFile, int nLine, const char *pExpression, int nStopProgram); +#endif + +#undef AGB_ASSERT +#ifdef NDEBUG +#define AGB_ASSERT(exp) +#else +#define AGB_ASSERT(exp) (exp) ? ((void*)0) : AGBAssert(__FILE__, __LINE__, #exp, 1); +#endif + +#undef AGB_WARNING +#ifdef NDEBUG +#define AGB_WARNING(exp) +#else +#define AGB_WARNING(exp) (exp) ? ((void*)0) : AGBAssert(__FILE__, __LINE__, #exp, 0); +#endif + +// for matching purposes + +#ifdef NDEBUG +#define AGB_ASSERT_EX(exp, file, line) +#else +#define AGB_ASSERT_EX(exp, file, line) (exp) ? ((void*)0) : AGBAssert(file, line, #exp, 1); +#endif + +#ifdef NDEBUG +#define AGB_WARNING_EX(exp, file, line) +#else +#define AGB_WARNING_EX(exp, file, line) (exp) ? ((void*)0) : AGBAssert(file, line, #exp, 0); +#endif + +#endif // GUARD_GBA_ISAGBPRINT_H diff --git a/include/global.h b/include/global.h index 7943fc569..3e260fd2a 100644 --- a/include/global.h +++ b/include/global.h @@ -1,8 +1,8 @@ #ifndef GUARD_GLOBAL_H #define GUARD_GLOBAL_H +#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 "config.h" // Prevent cross-jump optimization. #define BLOCK_CROSS_JUMP asm(""); |