diff options
author | ProjectRevoTPP <projectrevotpp@hotmail.com> | 2018-01-02 00:53:26 -0500 |
---|---|---|
committer | ProjectRevoTPP <projectrevotpp@hotmail.com> | 2018-01-02 00:53:26 -0500 |
commit | d50dcfcdd37aedab6352e4953cb2be04f2691113 (patch) | |
tree | 50bddcab4522f8a9c18afcef425a41a68474c4fb /src | |
parent | d6f88aaae447dbc22ff5fa289343343e7034263b (diff) |
add no print support.
Diffstat (limited to 'src')
-rwxr-xr-x | src/libs/libisagbprn.c | 44 |
1 files changed, 34 insertions, 10 deletions
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 |