diff options
-rwxr-xr-x | include/assert.h | 43 | ||||
-rw-r--r-- | include/config.h | 4 | ||||
-rw-r--r-- | include/gba/gba.h | 1 | ||||
-rwxr-xr-x | include/gba/isagbprint.h | 50 | ||||
-rw-r--r-- | include/global.h | 3 | ||||
-rw-r--r-- | src/engine/main.c | 4 | ||||
-rwxr-xr-x | src/libs/libisagbprn.c | 2 |
7 files changed, 57 insertions, 50 deletions
diff --git a/include/assert.h b/include/assert.h deleted file mode 100755 index 0c1e5bf77..000000000 --- a/include/assert.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef GUARD_GBASDKASSERT_H -#define GUARD_GBASDKASSERT_H - -// this header is based on the -// GBA SDK IsAgbAssert.h. - -#ifdef NOAGBPRN - #define AGBPrintInit() - #define AGBPutc(pBuf) - #define AGBPrint(pBuf) - #define AGBPrintf(...) - #define AGBPrintFlush1Block() - #define AGBPrintFlush() - #define AGBAssert(pFile, nLine, pExpression, nStopProgram) -#else - // without NOAGBPRN defined, this enables asserts for usage - // on a standard GBA debugger unit or in emulators that - // support it. - - void AGBPrintInit(void); - void AGBPutc(const char pBuf); - 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 - -// when using AGB_WARNING, be sure to flush after as AGBAssert does not flush the string to console -// immediately after usage. -#ifdef NOAGBPRN - #define AGB_ASSERT(expression) -#else - #define AGB_ASSERT(expression) (expression) ? ((void *)0) : AGBAssert(__FILE__, __LINE__, #expression, 1); -#endif - -#ifdef NOAGBPRN - #define AGB_WARNING(expression) -#else - #define AGB_WARNING(expression) (expression) ? ((void *)0) : AGBAssert(__FILE__, __LINE__, #expression, 0); -#endif - -#endif diff --git a/include/config.h b/include/config.h index d9ed70a7c..7661324db 100644 --- a/include/config.h +++ b/include/config.h @@ -4,7 +4,7 @@ // 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 NOAGBPRN before release, which is actually supposed to be +// to define NDEBUG before release, which is actually supposed to be // NDEBUG, however this has been changed as Ruby's actual debug build // does not use the AGBPrint features. @@ -15,7 +15,7 @@ // authoritative. These additions are for user convenience based on // officially recommended SDK practices for debugging and is therefore // still in part authoritative. -#define NOAGBPRN +#define NDEBUG #ifndef REVISION #define REVISION 0 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 4c118db13..d0af4a4d1 100644 --- a/include/global.h +++ b/include/global.h @@ -1,9 +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" -#include "assert.h" // IDE support #if defined(__APPLE__) || defined(__CYGWIN__) diff --git a/src/engine/main.c b/src/engine/main.c index e52551f72..92b81d475 100644 --- a/src/engine/main.c +++ b/src/engine/main.c @@ -83,7 +83,7 @@ static void WaitForVBlank(void); #define B_START_SELECT (B_BUTTON | START_BUTTON | SELECT_BUTTON) -#ifndef NOAGBPRN +#ifndef NDEBUG #include <stdlib.h> // don't include if not needed. #endif @@ -105,7 +105,7 @@ void AgbMain() // In Fire Red, AGBPrintInit is called at this spot. For user convenience, I // opt to initialize the print area here. It is up to the user where they choose // to print stuff from, as anything else declared is NOT authoritative. -#ifndef NOAGBPRN +#ifndef NDEBUG AGBPrintInit(); __mb_cur_max = 1; // fix for AGBPrintf #endif diff --git a/src/libs/libisagbprn.c b/src/libs/libisagbprn.c index 867044217..eccc31f48 100755 --- a/src/libs/libisagbprn.c +++ b/src/libs/libisagbprn.c @@ -25,7 +25,7 @@ struct AGBPrintStruct typedef void (*LPFN_PRINT_FLUSH)(void); -#ifndef NOAGBPRN +#ifndef NDEBUG void AGBPrintFlush1Block(void); void AGBPrintInit(void) |