summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Huderle <huderlem@gmail.com>2018-01-11 18:11:01 -0800
committerGitHub <noreply@github.com>2018-01-11 18:11:01 -0800
commit72af1f78801e9a05d34a9416dd460b4e888d18a1 (patch)
treeb580a5df2085135c0982846ddc6a334888749d07
parent83b3cafa321b312f347c044f2c41e1c9803a4106 (diff)
parentbdf242c2876ce95673de446cbaea9498dc77d8ed (diff)
Merge pull request #1 from ProjectRevoTPP/assert
add NDEBUG define
-rw-r--r--include/config.h12
-rw-r--r--include/global.h2
-rw-r--r--ld_script.txt35
-rw-r--r--src/isagbprn.c30
-rw-r--r--sym_bss.txt36
5 files changed, 43 insertions, 72 deletions
diff --git a/include/config.h b/include/config.h
index 162af3143..756fd1ebd 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1,6 +1,18 @@
#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 NDEBUG before release, however this has been changed as
+// Ruby's actual debug build does not use the AGBPrint features.
+// #define NDEBUG
+
+// Fire Red likely forgot to define NDEBUG/NOAGBPRN before release, leading
+// to the inclusion of asserts in the retail ROM. Don't try to re-enable this yet
+// since not all baseroms and pointers have been dumped yet and will result in
+// a broken ROM.
+
#define ENGLISH
#ifdef ENGLISH
diff --git a/include/global.h b/include/global.h
index 50d3f9104..dd466678d 100644
--- a/include/global.h
+++ b/include/global.h
@@ -1,8 +1,8 @@
#ifndef GUARD_GLOBAL_H
#define GUARD_GLOBAL_H
-#include "gba/gba.h"
#include "config.h"
+#include "gba/gba.h"
// Prevent cross-jump optimization.
#define BLOCK_CROSS_JUMP asm("");
diff --git a/ld_script.txt b/ld_script.txt
index 2b0e94aab..798d3ff4d 100644
--- a/ld_script.txt
+++ b/ld_script.txt
@@ -15,44 +15,9 @@ SECTIONS {
<EWRAM>
- tools/agbcc/lib/libc.a:memcpy.o(.data);
- tools/agbcc/lib/libc.a:memset.o(.data);
- tools/agbcc/lib/libc.a:strcmp.o(.data);
- tools/agbcc/lib/libc.a:strcpy.o(.data);
tools/agbcc/lib/libc.a:impure.o(.data);
- tools/agbcc/lib/libc.a:vsprintf.o(.data);
- tools/agbcc/lib/libc.a:vfprintf.o(.data);
- tools/agbcc/lib/libc.a:wsetup.o(.data);
- tools/agbcc/lib/libc.a:dtoa.o(.data);
- tools/agbcc/lib/libc.a:fflush.o(.data);
- tools/agbcc/lib/libc.a:findfp.o(.data);
- tools/agbcc/lib/libc.a:freer.o(.data);
- tools/agbcc/lib/libc.a:mtrim.o(.data);
- tools/agbcc/lib/libc.a:fvwrite.o(.data);
- tools/agbcc/lib/libc.a:fwalk.o(.data);
tools/agbcc/lib/libc.a:locale.o(.data);
- tools/agbcc/lib/libc.a:makebuf.o(.data);
tools/agbcc/lib/libc.a:mallocr.o(.data);
- tools/agbcc/lib/libc.a:mbtowc_r.o(.data);
- tools/agbcc/lib/libc.a:memchr.o(.data);
- tools/agbcc/lib/libc.a:memmove.o(.data);
- tools/agbcc/lib/libc.a:mlock.o(.data);
- tools/agbcc/lib/libc.a:mprec.o(.data);
- tools/agbcc/lib/libc.a:s_isinf.o(.data);
- tools/agbcc/lib/libc.a:s_isnan.o(.data);
- tools/agbcc/lib/libc.a:sbrkr.o(.data);
- tools/agbcc/lib/libc.a:stdio.o(.data);
- tools/agbcc/lib/libc.a:strlen.o(.data);
- tools/agbcc/lib/libc.a:syscalls.o(.data);
- tools/agbcc/lib/libc.a:writer.o(.data);
- tools/agbcc/lib/libc.a:callocr.o(.data);
- tools/agbcc/lib/libc.a:closer.o(.data);
- tools/agbcc/lib/libc.a:errno.o(.data);
- tools/agbcc/lib/libc.a:fstatr.o(.data);
- tools/agbcc/lib/libc.a:libcfunc.o(.data);
- tools/agbcc/lib/libc.a:lseekr.o(.data);
- tools/agbcc/lib/libc.a:readr.o(.data);
-
. = 0x40000;
}
diff --git a/src/isagbprn.c b/src/isagbprn.c
index 63e372ca2..3fd5e9142 100644
--- a/src/isagbprn.c
+++ b/src/isagbprn.c
@@ -1,5 +1,7 @@
#include <stdarg.h>
#include <stdio.h>
+#include "global.h"
+#include "config.h"
#include "gba/gba.h"
#define AGB_PRINT_FLUSH_ADDR 0x9FE209D
@@ -7,6 +9,12 @@
#define AGB_PRINT_PROTECT_ADDR 0x9FE2FFE
#define WSCNT_DATA (WAITCNT_PHI_OUT_16MHZ | WAITCNT_WS0_S_2 | WAITCNT_WS0_N_4)
+// originally for auto no$gba support, the string "no$gba" should be at this address,
+// the user needs to read this string out as the memory viewer won't show it.
+#define NOCASHGBAIDADDR 0x4FFFA00
+#define NOCASHGBAPRINTADDR1 0x4FFFA10 // automatically adds a newline after the string has finished
+#define NOCASHGBAPRINTADDR2 0x4FFFA14 // does not automatically add the newline. by default, NOCASHGBAPRINTADDR2 is used. this is used to keep strings consistent between no$gba and VBA-RR, but a user can choose to forgo this.
+
struct AGBPrintStruct
{
u16 m_nRequest;
@@ -17,6 +25,8 @@ struct AGBPrintStruct
typedef void (*LPFN_PRINT_FLUSH)(void);
+#ifndef NDEBUG
+
void AGBPrintFlush1Block(void);
void AGBPrintInit(void)
@@ -146,3 +156,23 @@ void AGBAssert(const char *pFile, int nLine, const char *pExpression, int nStopP
AGBPrintf("WARING FILE=[%s] LINE=[%d] EXP=[%s] \n", pFile, nLine, pExpression);
}
}
+
+// no$gba print functions, uncomment to use
+/*
+void NoCashGBAPrint(const char *pBuf)
+{
+ *(volatile u32*)NOCASHGBAPRINTADDR2 = (u32)pBuf;
+}
+
+void NoCashGBAPrintf(const char *pBuf, ...)
+{
+ char bufPrint[0x100];
+ va_list vArgv;
+ va_start(vArgv, pBuf);
+ vsprintf(bufPrint, pBuf, vArgv);
+ va_end(vArgv);
+ NoCashGBAPrint(bufPrint);
+}
+*/
+
+#endif
diff --git a/sym_bss.txt b/sym_bss.txt
index 4014026ab..394e77647 100644
--- a/sym_bss.txt
+++ b/sym_bss.txt
@@ -286,40 +286,4 @@ gUnknown_3002080: @ 3002080
.include "tools/agbcc/lib/libgcc.a:dp-bit.o"
.include "tools/agbcc/lib/libgcc.a:fp-bit.o"
- .include "tools/agbcc/lib/libc.a:memcpy.o"
- .include "tools/agbcc/lib/libc.a:memset.o"
- .include "tools/agbcc/lib/libc.a:strcmp.o"
- .include "tools/agbcc/lib/libc.a:strcpy.o"
- .include "tools/agbcc/lib/libc.a:impure.o"
- .include "tools/agbcc/lib/libc.a:vsprintf.o"
- .include "tools/agbcc/lib/libc.a:vfprintf.o"
- .include "tools/agbcc/lib/libc.a:wsetup.o"
- .include "tools/agbcc/lib/libc.a:dtoa.o"
- .include "tools/agbcc/lib/libc.a:fflush.o"
- .include "tools/agbcc/lib/libc.a:findfp.o"
- .include "tools/agbcc/lib/libc.a:freer.o"
- .include "tools/agbcc/lib/libc.a:mtrim.o"
- .include "tools/agbcc/lib/libc.a:fvwrite.o"
- .include "tools/agbcc/lib/libc.a:fwalk.o"
- .include "tools/agbcc/lib/libc.a:locale.o"
- .include "tools/agbcc/lib/libc.a:makebuf.o"
- .include "tools/agbcc/lib/libc.a:mallocr.o"
- .include "tools/agbcc/lib/libc.a:mbtowc_r.o"
- .include "tools/agbcc/lib/libc.a:memchr.o"
- .include "tools/agbcc/lib/libc.a:memmove.o"
- .include "tools/agbcc/lib/libc.a:mlock.o"
- .include "tools/agbcc/lib/libc.a:mprec.o"
- .include "tools/agbcc/lib/libc.a:s_isinf.o"
- .include "tools/agbcc/lib/libc.a:s_isnan.o"
- .include "tools/agbcc/lib/libc.a:sbrkr.o"
- .include "tools/agbcc/lib/libc.a:stdio.o"
- .include "tools/agbcc/lib/libc.a:strlen.o"
.include "tools/agbcc/lib/libc.a:syscalls.o"
- .include "tools/agbcc/lib/libc.a:writer.o"
- .include "tools/agbcc/lib/libc.a:callocr.o"
- .include "tools/agbcc/lib/libc.a:closer.o"
- .include "tools/agbcc/lib/libc.a:errno.o"
- .include "tools/agbcc/lib/libc.a:fstatr.o"
- .include "tools/agbcc/lib/libc.a:libcfunc.o"
- .include "tools/agbcc/lib/libc.a:lseekr.o"
- .include "tools/agbcc/lib/libc.a:readr.o"