diff options
-rwxr-xr-x | include/assert.h | 14 | ||||
-rwxr-xr-x | src/libs/libisagbprn.c | 44 |
2 files changed, 47 insertions, 11 deletions
diff --git a/include/assert.h b/include/assert.h index 7a5e727e2..d724290fa 100755 --- a/include/assert.h +++ b/include/assert.h @@ -16,6 +16,16 @@ // without NOAGBPRN defined, this enables asserts for usage // on a standard GBA debugger unit or in emulators that // support it. + +// no$gba support, due to the different method no$gba uses to print debug strings. +// currently cannot use IsNoGba due to no$gba doing a gloriously fuck up of a job and +// breaking the version identifier. +#define AGBPrint(pBuf) \ +{ \ + NOGBAPrint(pBuf); \ + AGBPrint(pBuf); \ +} + void AGBPrintInit(void); void AGBPutc(const char pBuf); void AGBPrint(const char *pBuf); @@ -23,6 +33,9 @@ void AGBPrintFlush1Block(void); void AGBPrintFlush(void); void AGBAssert(const char *pFile, int nLine, const char *pExpression, int nStopProgram); + // NOGBA PROTOTYPES FOR LIBISAGBPRN.C + bool32 IsNoGba(void); + void NOGBAPrint(const char *pBuf); #endif // when using AGB_WARNING, be sure to flush after as AGBAssert does not flush the string to console @@ -39,5 +52,4 @@ #define AGB_WARNING(expression) (expression) ? ((void *)0) : AGBAssert(__FILE__, __LINE__, #expression, 0); #endif - #endif diff --git a/src/libs/libisagbprn.c b/src/libs/libisagbprn.c index 64ccb6351..9691d1b90 100755 --- a/src/libs/libisagbprn.c +++ b/src/libs/libisagbprn.c @@ -2,12 +2,17 @@ #include <stdio.h> #include "gba/gba.h" #include "config.h" +#include "assert.h" #define AGB_PRINT_FLUSH_ADDR 0x9FE209D #define AGB_PRINT_STRUCT_ADDR 0x9FE20F8 #define AGB_PRINT_PROTECT_ADDR 0x9FE2FFE #define WSCNT_DATA (WAITCNT_PHI_OUT_16MHZ | WAITCNT_WS0_S_2 | WAITCNT_WS0_N_4) +// for auto no$gba support, the string "no$gba" should be at this address. +#define NOGBAIDADDR 0x4FFFA00 +#define NOGBAPRINTADDR 0x4FFFA14 + struct AGBPrintStruct { u16 m_nRequest; @@ -61,18 +66,29 @@ void AGBPutc(const char cChr) AGBPrintFlush1Block(); } +#undef AGBPrint // dont break the function + void AGBPrint(const char *pBuf) { - volatile struct AGBPrintStruct *pPrint = (struct AGBPrintStruct *)AGB_PRINT_STRUCT_ADDR; - u16 *pWSCNT = (u16 *)REG_ADDR_WAITCNT; - u16 nOldWSCNT = *pWSCNT; - *pWSCNT = WSCNT_DATA; - while (*pBuf) - { - AGBPutc(*pBuf); - pBuf++; - } - *pWSCNT = nOldWSCNT; + volatile struct AGBPrintStruct *pPrint = (struct AGBPrintStruct *)AGB_PRINT_STRUCT_ADDR; + u16 *pWSCNT = (u16 *)REG_ADDR_WAITCNT; + u16 nOldWSCNT = *pWSCNT; + *pWSCNT = WSCNT_DATA; + while (*pBuf) + { + AGBPutc(*pBuf); + pBuf++; + } + *pWSCNT = nOldWSCNT; +} + +// I have to define this twice to avoid messing AGBPrint up. If there's a better way of doing this, please fix it. +// currently cannot use IsNoGba due to no$gba doing a gloriously fuck up of a job and +// breaking the version identifier. +#define AGBPrint(pBuf) \ +{ \ + NOGBAPrint(pBuf); \ + AGBPrint(pBuf); \ } void AGBPrintf(const char *pBuf, ...) @@ -148,4 +164,12 @@ void AGBAssert(const char *pFile, int nLine, const char *pExpression, int nStopP AGBPrintf("WARING FILE=[%s] LINE=[%d] EXP=[%s] \n", pFile, nLine, pExpression); } } + +// nogba print function + +void NOGBAPrint(const char *pBuf) +{ + *(volatile u32*)NOGBAPRINTADDR = (u32)pBuf; +} + #endif |