X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fdebug.c;h=9bdf5d1344138d23e3d12d32de5f319303ff443c;hb=5e41feadc19dbc9cda954543cf2b2649ced835b4;hp=e983ff6084e651755efe8aff971e52426ac83c3f;hpb=5d7112b5fad9e69a556898a705eeef2307bb83d9;p=gbajam22 diff --git a/src/debug.c b/src/debug.c index e983ff6..9bdf5d1 100644 --- a/src/debug.c +++ b/src/debug.c @@ -1,4 +1,5 @@ #include +#include #include #include #include "gbaregs.h" @@ -130,22 +131,40 @@ int dbg_drawstr(int x, int y, const char *fmt, ...) } #ifdef EMUBUILD -__attribute__((target("arm"))) +#define REG_DBG_ENABLE REG16(0xfff780) +#define REG_DBG_FLAGS REG16(0xfff700) +#define REG_DBG_STR REG8(0xfff600) + +/*__attribute__((target("arm")))*/ void emuprint(const char *fmt, ...) { + static int opened; char buf[128]; va_list ap; + if(!opened) { + REG_DBG_ENABLE = 0xc0de; + if(REG_DBG_ENABLE != 0x1dea) { + return; + } + opened = 1; + } + va_start(ap, fmt); vsnprintf(buf, sizeof buf, fmt, ap); va_end(ap); + strcpy((char*)0x4fff600, buf); + REG_DBG_FLAGS = 0x104; /* debug message */ + + /* asm volatile( "mov r0, %0\n\t" "swi 0xff0000\n\t" : : "r" (buf) : "r0" ); + */ } #else void emuprint(const char *fmt, ...)