summaryrefslogtreecommitdiff
path: root/include/assert.h
diff options
context:
space:
mode:
authorProjectRevoTPP <projectrevotpp@hotmail.com>2017-12-20 15:33:08 -0500
committerProjectRevoTPP <projectrevotpp@hotmail.com>2017-12-20 15:33:08 -0500
commit272cd213391b5ce87cb2aeac263b3eedb0f19a07 (patch)
treeceffa6e21c4e0b3cf74ca48ae7e4343d9341b809 /include/assert.h
parent3c5f725de49371aced1788a21f5e53df5b498b5f (diff)
Add NDEBUG (NOAGBPRN) support to pokeruby.
Diffstat (limited to 'include/assert.h')
-rwxr-xr-xinclude/assert.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/include/assert.h b/include/assert.h
new file mode 100755
index 000000000..7a5e727e2
--- /dev/null
+++ b/include/assert.h
@@ -0,0 +1,43 @@
+#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