From 272cd213391b5ce87cb2aeac263b3eedb0f19a07 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Wed, 20 Dec 2017 15:33:08 -0500 Subject: Add NDEBUG (NOAGBPRN) support to pokeruby. --- Makefile | 7 ++- include/assert.h | 43 ++++++++++++++ include/config.h | 16 ++++++ include/global.h | 1 + ld_script.txt | 87 +++++++++++++++++++++++++++- src/engine/main.c | 7 +++ src/libs/libc.c | 143 ---------------------------------------------- src/libs/libisagbprn.c | 151 +++++++++++++++++++++++++++++++++++++++++++++++++ sym_bss.txt | 37 ++++++++++++ 9 files changed, 346 insertions(+), 146 deletions(-) create mode 100755 include/assert.h delete mode 100644 src/libs/libc.c create mode 100755 src/libs/libisagbprn.c diff --git a/Makefile b/Makefile index e7e2a7156..c3df6d65f 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,8 @@ OBJCOPY := $(DEVKITARM)/bin/arm-none-eabi-objcopy LIBGCC := tools/agbcc/lib/libgcc.a +LIBC := tools/agbcc/lib/libc.a + SHA1 := sha1sum -c GFX := tools/gbagfx/gbagfx @@ -103,6 +105,9 @@ sound/songs/%.s: sound/songs/%.mid %src/libs/m4a_2.o: CC1 := tools/agbcc/bin/old_agbcc %src/libs/m4a_4.o: CC1 := tools/agbcc/bin/old_agbcc +%src/libs/libisagbprn.o: CC1 := tools/agbcc/bin/old_agbcc +%src/libs/libisagbprn.o: CFLAGS := -mthumb-interwork + $(SONG_OBJS): %.o: %.s $(AS) $(ASFLAGS) -I sound -o $@ $< @@ -161,7 +166,7 @@ build/$1/ld_script.ld: ld_script.txt build/$1/sym_bss.ld build/$1/sym_common.ld cd build/$1 && sed -f ../../ld_script.sed ../../ld_script.txt | sed "s#tools/#../../tools/#g" | sed "s#sound/#../../sound/#g" >ld_script.ld poke$1.elf: build/$1/ld_script.ld $$($1_OBJS) - cd build/$1 && $$(LD) -T ld_script.ld -Map ../../poke$1.map -o ../../$$@ $$($1_OBJS_REL) ../../$$(LIBGCC) + cd build/$1 && $$(LD) -T ld_script.ld -Map ../../poke$1.map -o ../../$$@ $$($1_OBJS_REL) ../../$$(LIBGCC) ../../$$(LIBC) poke$1.gba: %.gba: %.elf $$(OBJCOPY) -O binary --gap-fill 0xFF --pad-to 0x9000000 $$< $$@ diff --git a/include/assert.h b/include/assert.h new file mode 100755 index 000000000..7a5e727e2 --- /dev/null +++ b/include/assert.h @@ -0,0 +1,43 @@ +#ifndef GUARD_GBASDKASSERT_H +#define GUARD_GBASDKASSERT_H + +// this header is based on the +// GBA SDK IsAgbAssert.h. + +#ifdef NOAGBPRN + #define AGBPrintInit() + #define AGBPutc(pBuf) + #define AGBPrint(pBuf) + #define AGBPrintf(...) + #define AGBPrintFlush1Block() + #define AGBPrintFlush() + #define AGBAssert(pFile, nLine, pExpression, nStopProgram) +#else + // without NOAGBPRN defined, this enables asserts for usage + // on a standard GBA debugger unit or in emulators that + // support it. + void AGBPrintInit(void); + void AGBPutc(const char pBuf); + void AGBPrint(const char *pBuf); + void AGBPrintf(const char *pBuf, ...); + void AGBPrintFlush1Block(void); + void AGBPrintFlush(void); + void AGBAssert(const char *pFile, int nLine, const char *pExpression, int nStopProgram); +#endif + +// when using AGB_WARNING, be sure to flush after as AGBAssert does not flush the string to console +// immediately after usage. +#ifdef NOAGBPRN + #define AGB_ASSERT(expression) +#else + #define AGB_ASSERT(expression) (expression) ? ((void *)0) : AGBAssert(__FILE__, __LINE__, #expression, 1); +#endif + +#ifdef NOAGBPRN + #define AGB_WARNING(expression) +#else + #define AGB_WARNING(expression) (expression) ? ((void *)0) : AGBAssert(__FILE__, __LINE__, #expression, 0); +#endif + + +#endif diff --git a/include/config.h b/include/config.h index 6a77c4c74..d9ed70a7c 100644 --- a/include/config.h +++ b/include/config.h @@ -1,6 +1,22 @@ #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. + +// To note, Ruby/Sapphire likely did not use AGBPrint. This is because +// the german debug ROM of Ruby did not have any uses of AGBPrint and +// the assert commands but instead a "crash" screen. This config exists +// for convenience for the user of pokeruby and NOT because it is +// authoritative. These additions are for user convenience based on +// officially recommended SDK practices for debugging and is therefore +// still in part authoritative. +#define NOAGBPRN + #ifndef REVISION #define REVISION 0 #endif diff --git a/include/global.h b/include/global.h index 6670f3837..7bd82f74e 100644 --- a/include/global.h +++ b/include/global.h @@ -3,6 +3,7 @@ #include "gba/gba.h" #include "config.h" +#include "assert.h" // IDE support #ifdef __APPLE__ diff --git a/ld_script.txt b/ld_script.txt index 6353fceec..67c259177 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -11,6 +11,44 @@ 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; } @@ -24,10 +62,12 @@ SECTIONS { /* .bss.code starts at 0x3000F60 */ src/libs/m4a_2.o(.bss.code); + tools/agbcc/lib/libc.a:syscalls.o(.bss); /* COMMON starts at 0x3001760 */ - + unk_code_ram = .; + tools/agbcc/lib/libc.a:sbrkr.o(COMMON); . = 0x8000; } @@ -36,6 +76,7 @@ SECTIONS { .text : ALIGN(4) { + unk_code = .; asm/crt0.o(.text); src/engine/main.o(.text); src/engine/sprite.o(.text); @@ -389,6 +430,7 @@ SECTIONS { src/debug/unknown_debug_menu.o(.text); src/engine/name_string_util.o(.text); src/engine/menu_cursor.o(.text); + unk_code_end = .; } =0 script_data : @@ -432,9 +474,46 @@ SECTIONS { tools/agbcc/lib/libgcc.a:fp-bit.o(.text); tools/agbcc/lib/libgcc.a:_lshrdi3.o(.text); tools/agbcc/lib/libgcc.a:_negdi2.o(.text); - src/libs/libc.o(.text); + tools/agbcc/lib/libc.a:memcpy.o(.text); + tools/agbcc/lib/libc.a:memset.o(.text); + tools/agbcc/lib/libc.a:strcmp.o(.text); + tools/agbcc/lib/libc.a:vfprintf.o(.text); + tools/agbcc/lib/libc.a:vsprintf.o(.text); + tools/agbcc/lib/libc.a:fvwrite.o(.text); + tools/agbcc/lib/libc.a:locale.o(.text); + tools/agbcc/lib/libc.a:findfp.o(.text); + tools/agbcc/lib/libc.a:fflush.o(.text); + tools/agbcc/lib/libc.a:wsetup.o(.text); + tools/agbcc/lib/libc.a:mbtowc_r.o(.text); + tools/agbcc/lib/libc.a:s_isinf.o(.text); + tools/agbcc/lib/libc.a:s_isnan.o(.text); + tools/agbcc/lib/libc.a:memchr.o(.text); + tools/agbcc/lib/libc.a:strlen.o(.text); + tools/agbcc/lib/libc.a:dtoa.o(.text); + tools/agbcc/lib/libc.a:memmove.o(.text); + tools/agbcc/lib/libc.a:stdio.o(.text); + tools/agbcc/lib/libc.a:mprec.o(.text); + tools/agbcc/lib/libc.a:mallocr.o(.text); + tools/agbcc/lib/libc.a:fwalk.o(.text); + tools/agbcc/lib/libc.a:freer.o(.text); + tools/agbcc/lib/libc.a:makebuf.o(.text); + tools/agbcc/lib/libc.a:readr.o(.text); + tools/agbcc/lib/libc.a:writer.o(.text); + tools/agbcc/lib/libc.a:lseekr.o(.text); + tools/agbcc/lib/libc.a:closer.o(.text); + tools/agbcc/lib/libc.a:callocr.o(.text); + tools/agbcc/lib/libc.a:sbrkr.o(.text); + tools/agbcc/lib/libc.a:mlock.o(.text); + tools/agbcc/lib/libc.a:fstatr.o(.text); + tools/agbcc/lib/libc.a:libcfunc.o(.text); + tools/agbcc/lib/libc.a:syscalls.o(.text); + tools/agbcc/lib/libc.a:errno.o(.text); + src/libs/libisagbprn.o(.text); } =0 + unk_code_ram_end = unk_code_ram + (unk_code_end - unk_code); + end = unk_code_ram_end; + .rodata : ALIGN(4) { @@ -1037,6 +1116,10 @@ SECTIONS { src/libs/agb_flash_le.o(.rodata); src/libs/siirtc.o(.rodata); tools/agbcc/lib/libgcc.a:_udivdi3.o(.rodata); + tools/agbcc/lib/libc.a(.rodata); + tools/agbcc/lib/libc.a(.data); + tools/agbcc/lib/libc.a:syscalls.o(.rodata); + src/libs/libisagbprn.o(.rodata); } =0 . = 0x8D00000; diff --git a/src/engine/main.c b/src/engine/main.c index 82a5fffb4..11c540d07 100644 --- a/src/engine/main.c +++ b/src/engine/main.c @@ -98,6 +98,13 @@ void AgbMain() gSoftResetDisabled = FALSE; +// In Fire Red, AGBPrintInit is called at this spot. For user convenience, I +// opt to initialize the print area here. It is up to the user where they choose +// to print stuff from, as anything else declared is NOT authoritative. +#ifndef NOAGBPRN + AGBPrintInit(); +#endif + if (gFlashMemoryPresent != TRUE) SetMainCallback2(NULL); diff --git a/src/libs/libc.c b/src/libs/libc.c deleted file mode 100644 index 920673e3e..000000000 --- a/src/libs/libc.c +++ /dev/null @@ -1,143 +0,0 @@ -#include "global.h" -#include - -#define LBLOCKSIZE (sizeof(long)) - -// Nonzero if (long)X contains a NULL byte. -#define CONTAINSNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080) - -// Nonzero if X is not aligned on a "long" boundary. -#define UNALIGNED(X) ((long)X & (LBLOCKSIZE - 1)) - -void *memcpy(void *dst0, const void *src0, size_t len0) -{ - char *dst = dst0; - const char *src = src0; - long *aligned_dst; - const long *aligned_src; - unsigned int len = len0; - - // If the size is small, or either src or dst is unaligned, - // then go to the byte copy loop. This should be rare. - if (len >= 16 && !(UNALIGNED(src) | UNALIGNED(dst))) - { - aligned_dst = (long *)dst; - aligned_src = (long *)src; - - // Copy 4X long words at a time if possible. - while (len >= 16) - { - *aligned_dst++ = *aligned_src++; - *aligned_dst++ = *aligned_src++; - *aligned_dst++ = *aligned_src++; - *aligned_dst++ = *aligned_src++; - len -= 16; - } - - // Copy one long word at a time if possible - while (len >= 4) - { - *aligned_dst++ = *aligned_src++; - len -= 4; - } - - dst = (char *)aligned_dst; - src = (char *)aligned_src; - } - - // Pick up any remaining bytes with a byte copier. - while (len--) - *dst++ = *src++; - - return dst0; -} - -void *memset(void *m, int c, size_t n) -{ - char *s = (char *)m; - int count, i; - unsigned long buffer; - unsigned long *aligned_addr; - unsigned char *unaligned_addr; - - // If the size is small or m is unaligned, - // then go to the byte copy loop. This should be rare. - if (n >= LBLOCKSIZE && !UNALIGNED(m)) - { - // We know that n is large and m is word-aligned. - aligned_addr = (unsigned long *)m; - - // Store C into each char sized location in buffer so that - // we can set large blocks quickly. - c &= 0xFF; - if (LBLOCKSIZE == 4) - { - buffer = (c << 8) | c; - buffer |= (buffer << 16); - } - else - { - buffer = 0; - for (i = 0; i < LBLOCKSIZE; i++) - buffer = (buffer << 8) | c; - } - - while (n >= LBLOCKSIZE * 4) - { - *aligned_addr++ = buffer; - *aligned_addr++ = buffer; - *aligned_addr++ = buffer; - *aligned_addr++ = buffer; - n -= LBLOCKSIZE * 4; - } - while (n >= LBLOCKSIZE) - { - *aligned_addr++ = buffer; - n -= LBLOCKSIZE; - } - - s = (char *)aligned_addr; - } - - // Pick up the remainder with a bytewise loop. - while (n--) - *s++ = (char)c; - - return m; -} - -int strcmp(const char *s1, const char *s2) -{ - unsigned long *a1; - unsigned long *a2; - - // If s1 or s2 are unaligned, then skip this and compare bytes. - if (!(UNALIGNED(s1) | UNALIGNED(s2))) - { - // Compare them a word at a time. - a1 = (unsigned long *)s1; - a2 = (unsigned long *)s2; - while (*a1 == *a2) - { - // If *a1 == *a2, and we find a null in *a1, - // then the strings must be equal, so return zero. - if (CONTAINSNULL(*a1)) - return 0; - - a1++; - a2++; - } - - s1 = (char *)a1; - s2 = (char *)a2; - } - - // Check the remaining few bytes. - while (*s1 != '\0' && *s1 == *s2) - { - s1++; - s2++; - } - - return (*(unsigned char *) s1) - (*(unsigned char *) s2); -} diff --git a/src/libs/libisagbprn.c b/src/libs/libisagbprn.c new file mode 100755 index 000000000..64ccb6351 --- /dev/null +++ b/src/libs/libisagbprn.c @@ -0,0 +1,151 @@ +#include +#include +#include "gba/gba.h" +#include "config.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) + +struct AGBPrintStruct +{ + u16 m_nRequest; + u16 m_nBank; + u16 m_nGet; + u16 m_nPut; +}; + +typedef void (*LPFN_PRINT_FLUSH)(void); + +#ifndef NOAGBPRN +void AGBPrintFlush1Block(void); + +void AGBPrintInit(void) +{ + volatile struct AGBPrintStruct *pPrint = (struct AGBPrintStruct *)AGB_PRINT_STRUCT_ADDR; + u16 *pWSCNT = (u16 *)REG_ADDR_WAITCNT; + u16 *pProtect = (u16 *)AGB_PRINT_PROTECT_ADDR; + u16 nOldWSCNT = *pWSCNT; + *pWSCNT = WSCNT_DATA; + *pProtect = 0x20; + pPrint->m_nRequest = pPrint->m_nGet = pPrint->m_nPut = 0; + pPrint->m_nBank = 0xFD; + *pProtect = 0; + *pWSCNT = nOldWSCNT; +} + +static void AGBPutcInternal(const char cChr) +{ + volatile struct AGBPrintStruct *pPrint = (struct AGBPrintStruct *)AGB_PRINT_STRUCT_ADDR; + u16 *pPrintBuf = (u16 *)(0x8000000 + (pPrint->m_nBank << 16)); + u16 *pProtect = (u16 *)AGB_PRINT_PROTECT_ADDR; + u16 nData = pPrintBuf[pPrint->m_nPut / 2]; + *pProtect = 0x20; + nData = (pPrint->m_nPut & 1) ? (nData & 0xFF) | (cChr << 8) : (nData & 0xFF00) | cChr; + pPrintBuf[pPrint->m_nPut / 2] = nData; + pPrint->m_nPut++; + *pProtect = 0; +} + +void AGBPutc(const char cChr) +{ + u16 *pWSCNT = (u16 *)REG_ADDR_WAITCNT; + u16 nOldWSCNT = *pWSCNT; + volatile struct AGBPrintStruct *pPrint; + *pWSCNT = WSCNT_DATA; + AGBPutcInternal(cChr); + *pWSCNT = nOldWSCNT; + pPrint = (struct AGBPrintStruct *)AGB_PRINT_STRUCT_ADDR; + if (pPrint->m_nPut == ((pPrint->m_nGet - 1) & 0xFFFF)) + AGBPrintFlush1Block(); +} + +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; +} + +void AGBPrintf(const char *pBuf, ...) +{ + char bufPrint[0x100]; + va_list vArgv; + va_start(vArgv, pBuf); + vsprintf(bufPrint, pBuf, vArgv); + va_end(vArgv); + AGBPrint(bufPrint); +} + +static void AGBPrintTransferDataInternal(u32 bAllData) +{ + LPFN_PRINT_FLUSH lpfnFuncFlush; + u16 *pIME; + u16 nIME; + u16 *pWSCNT; + u16 nOldWSCNT; + u16 *pProtect; + volatile struct AGBPrintStruct *pPrint; + + pProtect = (u16 *)AGB_PRINT_PROTECT_ADDR; + pPrint = (struct AGBPrintStruct *)AGB_PRINT_STRUCT_ADDR; + lpfnFuncFlush = (LPFN_PRINT_FLUSH)AGB_PRINT_FLUSH_ADDR; + pIME = (u16 *)REG_ADDR_IME; + nIME = *pIME; + pWSCNT = (u16 *)REG_ADDR_WAITCNT; + nOldWSCNT = *pWSCNT; + *pIME = nIME & ~1; + *pWSCNT = WSCNT_DATA; + + if (bAllData) + { + while (pPrint->m_nPut != pPrint->m_nGet) + { + *pProtect = 0x20; + lpfnFuncFlush(); + *pProtect = 0; + } + } + else if (pPrint->m_nPut != pPrint->m_nGet) + { + *pProtect = 0x20; + lpfnFuncFlush(); + *pProtect = 0; + } + + *pWSCNT = nOldWSCNT; + *pIME = nIME; +} + +void AGBPrintFlush1Block(void) +{ + AGBPrintTransferDataInternal(FALSE); +} + +void AGBPrintFlush(void) +{ + AGBPrintTransferDataInternal(TRUE); +} + +void AGBAssert(const char *pFile, int nLine, const char *pExpression, int nStopProgram) +{ + if (nStopProgram) + { + AGBPrintf("ASSERTION FAILED FILE=[%s] LINE=[%d] EXP=[%s] \n", pFile, nLine, pExpression); + AGBPrintFlush(); + asm(".hword 0xEFFF"); + } + else + { + AGBPrintf("WARING FILE=[%s] LINE=[%d] EXP=[%s] \n", pFile, nLine, pExpression); + } +} +#endif diff --git a/sym_bss.txt b/sym_bss.txt index 6587c2c39..ff3b3de01 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -39,3 +39,40 @@ .include "src/libs/siirtc.o" .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 a3c7adb2ede2aead120f763bc49306caf69be9e4 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Wed, 27 Dec 2017 20:58:19 -0500 Subject: simplify linker script additions for assert support --- ld_script.txt | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/ld_script.txt b/ld_script.txt index 3e8f45121..18158ecfe 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -66,8 +66,8 @@ SECTIONS { /* COMMON starts at 0x3001760 */ - unk_code_ram = .; tools/agbcc/lib/libc.a:sbrkr.o(COMMON); + end = .; . = 0x8000; } @@ -76,7 +76,6 @@ SECTIONS { .text : ALIGN(4) { - unk_code = .; asm/crt0.o(.text); src/engine/main.o(.text); src/engine/sprite.o(.text); @@ -431,7 +430,6 @@ SECTIONS { src/debug/unknown_debug_menu.o(.text); src/engine/name_string_util.o(.text); src/engine/menu_cursor.o(.text); - unk_code_end = .; } =0 script_data : @@ -512,9 +510,6 @@ SECTIONS { src/libs/libisagbprn.o(.text); } =0 - unk_code_ram_end = unk_code_ram + (unk_code_end - unk_code); - end = unk_code_ram_end; - .rodata : ALIGN(4) { -- cgit v1.2.3 From d6f88aaae447dbc22ff5fa289343343e7034263b Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Thu, 28 Dec 2017 02:47:41 -0500 Subject: fix for printf --- src/engine/main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/engine/main.c b/src/engine/main.c index 11c540d07..e52551f72 100644 --- a/src/engine/main.c +++ b/src/engine/main.c @@ -83,6 +83,10 @@ static void WaitForVBlank(void); #define B_START_SELECT (B_BUTTON | START_BUTTON | SELECT_BUTTON) +#ifndef NOAGBPRN + #include // don't include if not needed. +#endif + void AgbMain() { RegisterRamReset(RESET_ALL); @@ -103,6 +107,7 @@ void AgbMain() // to print stuff from, as anything else declared is NOT authoritative. #ifndef NOAGBPRN AGBPrintInit(); + __mb_cur_max = 1; // fix for AGBPrintf #endif if (gFlashMemoryPresent != TRUE) -- cgit v1.2.3 From d50dcfcdd37aedab6352e4953cb2be04f2691113 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Tue, 2 Jan 2018 00:53:26 -0500 Subject: add no print support. --- include/assert.h | 14 +++++++++++++- 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 #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 -- cgit v1.2.3 From 6c5e0ef4d873ae89708b7ebc547f2243893359f4 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Tue, 2 Jan 2018 00:54:56 -0500 Subject: remove function that doesn't exist anymore. --- include/assert.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/assert.h b/include/assert.h index d724290fa..5a134d7c9 100755 --- a/include/assert.h +++ b/include/assert.h @@ -33,8 +33,7 @@ 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); + // NOGBA PROTOTYPE FOR LIBISAGBPRN.C void NOGBAPrint(const char *pBuf); #endif -- cgit v1.2.3 From ab06b56532026db85a9cba1c21c8b2235fcdf222 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Tue, 2 Jan 2018 00:56:11 -0500 Subject: formatting --- src/libs/libisagbprn.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libs/libisagbprn.c b/src/libs/libisagbprn.c index 9691d1b90..ef0d51f26 100755 --- a/src/libs/libisagbprn.c +++ b/src/libs/libisagbprn.c @@ -70,16 +70,16 @@ void AGBPutc(const char cChr) 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. -- cgit v1.2.3 From d4df8046d45e50e19d2305bd4388e47087949960 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Sat, 6 Jan 2018 21:52:05 -0500 Subject: use firered isagbprint.h and NDEBUG --- include/assert.h | 43 ----------------------------------------- include/config.h | 4 ++-- include/gba/gba.h | 1 + include/gba/isagbprint.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ include/global.h | 3 +-- src/engine/main.c | 4 ++-- src/libs/libisagbprn.c | 2 +- 7 files changed, 57 insertions(+), 50 deletions(-) delete mode 100755 include/assert.h create mode 100755 include/gba/isagbprint.h diff --git a/include/assert.h b/include/assert.h deleted file mode 100755 index 0c1e5bf77..000000000 --- a/include/assert.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef GUARD_GBASDKASSERT_H -#define GUARD_GBASDKASSERT_H - -// this header is based on the -// GBA SDK IsAgbAssert.h. - -#ifdef NOAGBPRN - #define AGBPrintInit() - #define AGBPutc(pBuf) - #define AGBPrint(pBuf) - #define AGBPrintf(...) - #define AGBPrintFlush1Block() - #define AGBPrintFlush() - #define AGBAssert(pFile, nLine, pExpression, nStopProgram) -#else - // without NOAGBPRN defined, this enables asserts for usage - // on a standard GBA debugger unit or in emulators that - // support it. - - void AGBPrintInit(void); - void AGBPutc(const char pBuf); - void AGBPrint(const char *pBuf); - void AGBPrintf(const char *pBuf, ...); - void AGBPrintFlush1Block(void); - void AGBPrintFlush(void); - void AGBAssert(const char *pFile, int nLine, const char *pExpression, int nStopProgram); -#endif - -// when using AGB_WARNING, be sure to flush after as AGBAssert does not flush the string to console -// immediately after usage. -#ifdef NOAGBPRN - #define AGB_ASSERT(expression) -#else - #define AGB_ASSERT(expression) (expression) ? ((void *)0) : AGBAssert(__FILE__, __LINE__, #expression, 1); -#endif - -#ifdef NOAGBPRN - #define AGB_WARNING(expression) -#else - #define AGB_WARNING(expression) (expression) ? ((void *)0) : AGBAssert(__FILE__, __LINE__, #expression, 0); -#endif - -#endif diff --git a/include/config.h b/include/config.h index d9ed70a7c..7661324db 100644 --- a/include/config.h +++ b/include/config.h @@ -4,7 +4,7 @@ // 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 +// to define NDEBUG 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. @@ -15,7 +15,7 @@ // authoritative. These additions are for user convenience based on // officially recommended SDK practices for debugging and is therefore // still in part authoritative. -#define NOAGBPRN +#define NDEBUG #ifndef REVISION #define REVISION 0 diff --git a/include/gba/gba.h b/include/gba/gba.h index 42ae3cdde..349344031 100644 --- a/include/gba/gba.h +++ b/include/gba/gba.h @@ -7,5 +7,6 @@ #include "gba/multiboot.h" #include "gba/syscall.h" #include "gba/macro.h" +#include "gba/isagbprint.h" #endif // GUARD_GBA_GBA_H diff --git a/include/gba/isagbprint.h b/include/gba/isagbprint.h new file mode 100755 index 000000000..c5eb456c3 --- /dev/null +++ b/include/gba/isagbprint.h @@ -0,0 +1,50 @@ +#ifndef GUARD_GBA_ISAGBPRINT_H +#define GUARD_GBA_ISAGBPRINT_H + +#ifdef NDEBUG +#define AGBPrintInit() +#define AGBPutc(cChr) +#define AGBPrint(pBuf) +#define AGBPrintf(pBuf, ...) +#define AGBPrintFlush1Block() +#define AGBPrintFlush() +#define AGBAssert(pFile, nLine, pExpression, nStopProgram) +#else +void AGBPrintInit(void); +void AGBPutc(const char cChr); +void AGBPrint(const char *pBuf); +void AGBPrintf(const char *pBuf, ...); +void AGBPrintFlush1Block(void); +void AGBPrintFlush(void); +void AGBAssert(const char *pFile, int nLine, const char *pExpression, int nStopProgram); +#endif + +#undef AGB_ASSERT +#ifdef NDEBUG +#define AGB_ASSERT(exp) +#else +#define AGB_ASSERT(exp) (exp) ? ((void*)0) : AGBAssert(__FILE__, __LINE__, #exp, 1); +#endif + +#undef AGB_WARNING +#ifdef NDEBUG +#define AGB_WARNING(exp) +#else +#define AGB_WARNING(exp) (exp) ? ((void*)0) : AGBAssert(__FILE__, __LINE__, #exp, 0); +#endif + +// for matching purposes + +#ifdef NDEBUG +#define AGB_ASSERT_EX(exp, file, line) +#else +#define AGB_ASSERT_EX(exp, file, line) (exp) ? ((void*)0) : AGBAssert(file, line, #exp, 1); +#endif + +#ifdef NDEBUG +#define AGB_WARNING_EX(exp, file, line) +#else +#define AGB_WARNING_EX(exp, file, line) (exp) ? ((void*)0) : AGBAssert(file, line, #exp, 0); +#endif + +#endif // GUARD_GBA_ISAGBPRINT_H diff --git a/include/global.h b/include/global.h index 4c118db13..d0af4a4d1 100644 --- a/include/global.h +++ b/include/global.h @@ -1,9 +1,8 @@ #ifndef GUARD_GLOBAL_H #define GUARD_GLOBAL_H +#include "config.h" // we need to define config before gba headers as print stuff needs the functions nulled before defines. #include "gba/gba.h" -#include "config.h" -#include "assert.h" // IDE support #if defined(__APPLE__) || defined(__CYGWIN__) diff --git a/src/engine/main.c b/src/engine/main.c index e52551f72..92b81d475 100644 --- a/src/engine/main.c +++ b/src/engine/main.c @@ -83,7 +83,7 @@ static void WaitForVBlank(void); #define B_START_SELECT (B_BUTTON | START_BUTTON | SELECT_BUTTON) -#ifndef NOAGBPRN +#ifndef NDEBUG #include // don't include if not needed. #endif @@ -105,7 +105,7 @@ void AgbMain() // In Fire Red, AGBPrintInit is called at this spot. For user convenience, I // opt to initialize the print area here. It is up to the user where they choose // to print stuff from, as anything else declared is NOT authoritative. -#ifndef NOAGBPRN +#ifndef NDEBUG AGBPrintInit(); __mb_cur_max = 1; // fix for AGBPrintf #endif diff --git a/src/libs/libisagbprn.c b/src/libs/libisagbprn.c index 867044217..eccc31f48 100755 --- a/src/libs/libisagbprn.c +++ b/src/libs/libisagbprn.c @@ -25,7 +25,7 @@ struct AGBPrintStruct typedef void (*LPFN_PRINT_FLUSH)(void); -#ifndef NOAGBPRN +#ifndef NDEBUG void AGBPrintFlush1Block(void); void AGBPrintInit(void) -- cgit v1.2.3 From 897107d1eae649e71213539aba7146fe2b2e2e70 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Sun, 7 Jan 2018 23:45:53 -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 7661324db..6d9e15a15 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 NDEBUG 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. // To note, Ruby/Sapphire likely did not use AGBPrint. This is because // the german debug ROM of Ruby did not have any uses of AGBPrint and -- cgit v1.2.3 From a289caaf97cddbf212fc860013b8815323a84921 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Mon, 8 Jan 2018 17:03:06 -0500 Subject: let the user deal with nogbaprint, forget this --- src/libs/libisagbprn.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/libs/libisagbprn.c b/src/libs/libisagbprn.c index eccc31f48..c066a41a0 100755 --- a/src/libs/libisagbprn.c +++ b/src/libs/libisagbprn.c @@ -2,16 +2,14 @@ #include #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) -// TODO: make no$gba support not shit - // 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 @@ -26,6 +24,7 @@ struct AGBPrintStruct typedef void (*LPFN_PRINT_FLUSH)(void); #ifndef NDEBUG + void AGBPrintFlush1Block(void); void AGBPrintInit(void) @@ -156,12 +155,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 1c6c7da6fba8903d8eff02ac12465a4098ebca47 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Mon, 8 Jan 2018 21:40:37 -0500 Subject: nogba to nocashgba --- Makefile | 2 -- src/libs/libisagbprn.c | 10 +++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 8ca249dc7..9aff29fc4 100644 --- a/Makefile +++ b/Makefile @@ -16,8 +16,6 @@ OBJCOPY := $(DEVKITARM)/bin/arm-none-eabi-objcopy LIBGCC := tools/agbcc/lib/libgcc.a LIBC := tools/agbcc/lib/libc.a -LIBC := tools/agbcc/lib/libc.a - SHA1 := sha1sum -c GFX := tools/gbagfx/gbagfx diff --git a/src/libs/libisagbprn.c b/src/libs/libisagbprn.c index c066a41a0..007f90bb7 100755 --- a/src/libs/libisagbprn.c +++ b/src/libs/libisagbprn.c @@ -10,8 +10,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 { @@ -155,11 +155,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 dcf12f9ecdbaab26afb8899eaa05f4cab09a5f82 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Mon, 8 Jan 2018 22:01:47 -0500 Subject: nocashgba printf --- include/config.h | 7 +++++++ src/libs/libisagbprn.c | 12 +++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/config.h b/include/config.h index 6d9e15a15..796da359c 100644 --- a/include/config.h +++ b/include/config.h @@ -16,6 +16,13 @@ // still in part authoritative. #define NDEBUG +// To enable print debugging, comment out "#define NDEBUG". This allows +// the various AGBPrint functions to be used. (See include/gba/isagbprint.h). +// Some emulators support a debug console window: uncomment NoCashGBAPrint() +// and NoCashGBAPrintf() in libisagbprn.c to use no$gba's own proprietary +// printing system. Use NoCashGBAPrint() and NoCashGBAPrintf() like you +// would normally use AGBPrint() and AGBPrintf(). + #ifndef REVISION #define REVISION 0 #endif diff --git a/src/libs/libisagbprn.c b/src/libs/libisagbprn.c index 007f90bb7..a9656f3c5 100755 --- a/src/libs/libisagbprn.c +++ b/src/libs/libisagbprn.c @@ -155,12 +155,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 2dd85b9f853f7d6774faaf52d908961695b3b112 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Tue, 9 Jan 2018 01:22:35 -0500 Subject: scrub ld_script for bloat --- include/config.h | 2 +- ld_script.txt | 40 ---------------------------------------- sym_bss.txt | 36 ------------------------------------ 3 files changed, 1 insertion(+), 77 deletions(-) diff --git a/include/config.h b/include/config.h index 796da359c..bd2ad3356 100644 --- a/include/config.h +++ b/include/config.h @@ -14,7 +14,7 @@ // authoritative. These additions are for user convenience based on // officially recommended SDK practices for debugging and is therefore // still in part authoritative. -#define NDEBUG +// #define NDEBUG // To enable print debugging, comment out "#define NDEBUG". This allows // the various AGBPrint functions to be used. (See include/gba/isagbprint.h). diff --git a/ld_script.txt b/ld_script.txt index 1e858cd69..6ae35f8df 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -11,44 +11,6 @@ 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; } @@ -62,7 +24,6 @@ SECTIONS { /* .bss.code starts at 0x3000F60 */ src/libs/m4a_2.o(.bss.code); - tools/agbcc/lib/libc.a:syscalls.o(.bss); /* COMMON starts at 0x3001760 */ @@ -1111,7 +1072,6 @@ SECTIONS { tools/agbcc/lib/libgcc.a:_udivdi3.o(.rodata); tools/agbcc/lib/libc.a(.rodata); tools/agbcc/lib/libc.a(.data); - tools/agbcc/lib/libc.a:syscalls.o(.rodata); src/libs/libisagbprn.o(.rodata); } =0 diff --git a/sym_bss.txt b/sym_bss.txt index 6e96a604c..16df5cef2 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -39,40 +39,4 @@ .include "src/libs/siirtc.o" .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 fc66800520a28a6940cee922b60074da1d624157 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Tue, 9 Jan 2018 01:23:11 -0500 Subject: you idiot, leave NDEBUG defined --- include/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/config.h b/include/config.h index bd2ad3356..796da359c 100644 --- a/include/config.h +++ b/include/config.h @@ -14,7 +14,7 @@ // authoritative. These additions are for user convenience based on // officially recommended SDK practices for debugging and is therefore // still in part authoritative. -// #define NDEBUG +#define NDEBUG // To enable print debugging, comment out "#define NDEBUG". This allows // the various AGBPrint functions to be used. (See include/gba/isagbprint.h). -- cgit v1.2.3 From 3c375850d12d774cb75803093ad80aa2783e4566 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Tue, 9 Jan 2018 19:28:01 -0500 Subject: comment --- src/libs/libisagbprn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/libisagbprn.c b/src/libs/libisagbprn.c index a9656f3c5..98231dcf5 100755 --- a/src/libs/libisagbprn.c +++ b/src/libs/libisagbprn.c @@ -8,8 +8,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 a51b95150ba86a3982f613886471626f742aeacd Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Tue, 9 Jan 2018 19:40:14 -0500 Subject: both print defines for nocashgba --- src/libs/libisagbprn.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/libisagbprn.c b/src/libs/libisagbprn.c index 98231dcf5..e0e979e95 100755 --- a/src/libs/libisagbprn.c +++ b/src/libs/libisagbprn.c @@ -11,7 +11,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 { @@ -159,7 +160,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 From f658a355e5434a647153d76087b50eec0d5041b1 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Thu, 11 Jan 2018 14:59:41 -0500 Subject: idiot, remove conflicts please --- Makefile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Makefile b/Makefile index 80f9d78df..8cbfd8245 100644 --- a/Makefile +++ b/Makefile @@ -160,12 +160,8 @@ include override.mk %.lz: % ; $(GBAGFX) $< $@ $(GFX_OPTS) %.rl: % ; $(GBAGFX) $< $@ $(GFX_OPTS) -<<<<<<< HEAD -======= - #### Sound Rules #### ->>>>>>> 62042c1cbf95b3f26fba3baa4f0a339f0b663462 sound/direct_sound_samples/cry_%.bin: sound/direct_sound_samples/cry_%.aif $(AIF2PCM) $< $@ --compress -- cgit v1.2.3