add assert support to pokeemerald.

This commit is contained in:
ProjectRevoTPP
2018-01-06 21:12:42 -05:00
parent 601ec28721
commit 7be61cfb1a
7 changed files with 175 additions and 176 deletions

43
include/assert.h Executable file
View File

@@ -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

View File

@@ -1,6 +1,16 @@
#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 NOAGBPRN 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.
#define NOAGBPRN
// 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

View File

@@ -3,6 +3,7 @@
#include "gba/gba.h"
#include "config.h"
#include "assert.h"
// Prevent cross-jump optimization.
#define BLOCK_CROSS_JUMP asm("");