From 5d7a038cea2cdb57df1354e8e9cbc57931cd4170 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Sat, 6 Jan 2018 21:29:51 -0500 Subject: add NDEBUG define --- include/config.h | 13 +++++++++++++ include/global.h | 2 +- src/isagbprn.c | 6 ++++++ sym_bss.txt | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/config.h b/include/config.h index 162af3143..6619cfa9a 100644 --- a/include/config.h +++ b/include/config.h @@ -1,6 +1,19 @@ #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 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/src/isagbprn.c b/src/isagbprn.c index 63e372ca2..18d342162 100644 --- a/src/isagbprn.c +++ b/src/isagbprn.c @@ -1,5 +1,7 @@ #include #include +#include "global.h" +#include "config.h" #include "gba/gba.h" #define AGB_PRINT_FLUSH_ADDR 0x9FE209D @@ -17,6 +19,8 @@ struct AGBPrintStruct typedef void (*LPFN_PRINT_FLUSH)(void); +#ifndef NDEBUG + void AGBPrintFlush1Block(void); void AGBPrintInit(void) @@ -146,3 +150,5 @@ void AGBAssert(const char *pFile, int nLine, const char *pExpression, int nStopP AGBPrintf("WARING FILE=[%s] LINE=[%d] EXP=[%s] \n", pFile, nLine, pExpression); } } + +#endif diff --git a/sym_bss.txt b/sym_bss.txt index 4014026ab..b3b7ae4b5 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -285,6 +285,7 @@ gUnknown_3002080: @ 3002080 .space 0x4 @ This isn't needed for Ruby/Sapphire or Emerald. .include "tools/agbcc/lib/libgcc.a:dp-bit.o" + .space 0x4 @ huh? .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" -- cgit v1.2.3 From 4e22639ab6dac73073a87b8e5a6464953abfd682 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Sat, 6 Jan 2018 21:33:02 -0500 Subject: remove unnecessary bss space --- sym_bss.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/sym_bss.txt b/sym_bss.txt index b3b7ae4b5..4014026ab 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -285,7 +285,6 @@ gUnknown_3002080: @ 3002080 .space 0x4 @ This isn't needed for Ruby/Sapphire or Emerald. .include "tools/agbcc/lib/libgcc.a:dp-bit.o" - .space 0x4 @ huh? .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" -- cgit v1.2.3 From d07e8b24fd20202f578e367533221586c585a7e5 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Sun, 7 Jan 2018 23:47:27 -0500 Subject: NDEBUG which is supposed to be NDEBUG... --- include/config.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/config.h b/include/config.h index 6619cfa9a..756fd1ebd 100644 --- a/include/config.h +++ b/include/config.h @@ -4,9 +4,8 @@ // 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. +// 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 -- cgit v1.2.3 From 5dd7baee5e9983c3a8199c785f276b600bd6bd93 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Mon, 8 Jan 2018 17:03:51 -0500 Subject: let the user deal with nogbaprint, forget this --- src/isagbprn.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/isagbprn.c b/src/isagbprn.c index 18d342162..5c897f16b 100644 --- a/src/isagbprn.c +++ b/src/isagbprn.c @@ -9,6 +9,11 @@ #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. +// except it's not, blame Martin, hence I'm letting the user deal with this nonsense. +#define NOGBAIDADDR 0x4FFFA00 +#define NOGBAPRINTADDR 0x4FFFA14 + struct AGBPrintStruct { u16 m_nRequest; @@ -151,4 +156,12 @@ void AGBAssert(const char *pFile, int nLine, const char *pExpression, int nStopP } } +// TODO: Find a way to seamlessly support no$gba without shit hack defines +// nogba print function +/* +void NOGBAPrint(const char *pBuf) +{ + *(volatile u32*)NOGBAPRINTADDR = (u32)pBuf; +}*/ + #endif -- cgit v1.2.3 From eb0635784ce23b38fb09d6ccb5dea75a3ed3ba0f Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Mon, 8 Jan 2018 17:05:02 -0500 Subject: actually change NOGBAPrint, stupid --- src/isagbprn.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/isagbprn.c b/src/isagbprn.c index 5c897f16b..91d5c3f08 100644 --- a/src/isagbprn.c +++ b/src/isagbprn.c @@ -156,12 +156,12 @@ void AGBAssert(const char *pFile, int nLine, const char *pExpression, int nStopP } } -// TODO: Find a way to seamlessly support no$gba without shit hack defines -// nogba print function +// nogba print function, uncomment to use /* void NOGBAPrint(const char *pBuf) { *(volatile u32*)NOGBAPRINTADDR = (u32)pBuf; -}*/ +} +*/ #endif -- cgit v1.2.3 From a8833519c9ccda46fe60b314f8e6624ca7388c8a Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Mon, 8 Jan 2018 21:42:19 -0500 Subject: nogba to nocashgba --- src/isagbprn.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/isagbprn.c b/src/isagbprn.c index 91d5c3f08..d2a41a9db 100644 --- a/src/isagbprn.c +++ b/src/isagbprn.c @@ -11,8 +11,8 @@ // for auto no$gba support, the string "no$gba" should be at this address. // except it's not, blame Martin, hence I'm letting the user deal with this nonsense. -#define NOGBAIDADDR 0x4FFFA00 -#define NOGBAPRINTADDR 0x4FFFA14 +#define NOCASHGBAIDADDR 0x4FFFA00 +#define NOCASHGBAPRINTADDR 0x4FFFA14 struct AGBPrintStruct { @@ -156,11 +156,11 @@ void AGBAssert(const char *pFile, int nLine, const char *pExpression, int nStopP } } -// nogba print function, uncomment to use +// no$gba print function, uncomment to use /* -void NOGBAPrint(const char *pBuf) +void NoCashGBAPrint(const char *pBuf) { - *(volatile u32*)NOGBAPRINTADDR = (u32)pBuf; + *(volatile u32*)NOCASHGBAPRINTADDR = (u32)pBuf; } */ -- cgit v1.2.3 From 149d308a67fe75781873c8da24a00e587935a689 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Mon, 8 Jan 2018 22:03:53 -0500 Subject: nocashgba printf --- src/isagbprn.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/isagbprn.c b/src/isagbprn.c index d2a41a9db..a2f9b5241 100644 --- a/src/isagbprn.c +++ b/src/isagbprn.c @@ -156,12 +156,22 @@ void AGBAssert(const char *pFile, int nLine, const char *pExpression, int nStopP } } -// no$gba print function, uncomment to use +// no$gba print functions, uncomment to use /* void NoCashGBAPrint(const char *pBuf) { *(volatile u32*)NOCASHGBAPRINTADDR = (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 -- cgit v1.2.3 From 57c9fd73b41fdb08af7914e4dafb82363d2f658a Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Tue, 9 Jan 2018 01:26:59 -0500 Subject: scrub ld_script for bloat --- ld_script.txt | 35 ----------------------------------- sym_bss.txt | 36 ------------------------------------ 2 files changed, 71 deletions(-) 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 { - 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/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" -- cgit v1.2.3 From 9e8079fc1bd201946a1bb667096b417cbf16ecbb Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Tue, 9 Jan 2018 19:28:58 -0500 Subject: comment --- src/isagbprn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/isagbprn.c b/src/isagbprn.c index a2f9b5241..52d7653bc 100644 --- a/src/isagbprn.c +++ b/src/isagbprn.c @@ -9,8 +9,8 @@ #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. -// except it's not, blame Martin, hence I'm letting the user deal with this nonsense. +// 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 NOCASHGBAPRINTADDR 0x4FFFA14 -- cgit v1.2.3 From bdf242c2876ce95673de446cbaea9498dc77d8ed Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Tue, 9 Jan 2018 19:39:29 -0500 Subject: both print defines for nocashgba --- src/isagbprn.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/isagbprn.c b/src/isagbprn.c index 52d7653bc..3fd5e9142 100644 --- a/src/isagbprn.c +++ b/src/isagbprn.c @@ -12,7 +12,8 @@ // 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 NOCASHGBAPRINTADDR 0x4FFFA14 +#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 { @@ -160,7 +161,7 @@ void AGBAssert(const char *pFile, int nLine, const char *pExpression, int nStopP /* void NoCashGBAPrint(const char *pBuf) { - *(volatile u32*)NOCASHGBAPRINTADDR = (u32)pBuf; + *(volatile u32*)NOCASHGBAPRINTADDR2 = (u32)pBuf; } void NoCashGBAPrintf(const char *pBuf, ...) -- cgit v1.2.3