From 7f001f81e7cbb76ffc2261e67c8b3b855e89269b Mon Sep 17 00:00:00 2001 From: Cuyler36 <24523422+Cuyler36@users.noreply.github.com> Date: Mon, 3 Jun 2024 17:22:36 -0400 Subject: [PATCH] Link jaudio_NES/aictrl.c --- common.py | 7 +++-- config/dol_slices.yml | 6 ++++ configure.py | 11 +++++-- include/dolphin/os.h | 47 +++++++++++++++--------------- include/dolphin/os/OSAlloc.h | 25 +++++++++++++--- include/jaudio_NES/audiostruct.h | 1 + include/jaudio_NES/dummyprobe.h | 6 ++-- src/static/jaudio_NES/dummyprobe.c | 8 ++--- 8 files changed, 70 insertions(+), 41 deletions(-) diff --git a/common.py b/common.py index 64d622c4..708e87ca 100644 --- a/common.py +++ b/common.py @@ -447,8 +447,9 @@ JAUDIO_BASE = CFLAGS + [ "-enum int", "-common on" ] + DOL_DEFINES -JAUDIO_SAMPLE = [ - "-func_align 32" +JAUDIO_FUNC_ALIGN_32 = [ + "-func_align 32", + "-str readonly" ] JSYSTEM_CFLAGS = ' '.join(JSYSTEM_BASE + LOCAL_CFLAGS) @@ -467,7 +468,7 @@ EXTERNAL_REL_CFLAGS = ' '.join(BASE_REL_CFLAGS) PREPROCESS_CFLAGS = ' '.join(PREPROCESSOR_CFLAGS) FAMICOM_CLFAGS = ' '.join(FAMICOM_BASE + LOCAL_CFLAGS) JAUDIO_CFLAGS = ' '.join(JAUDIO_BASE + LOCAL_CFLAGS) -JAUDIO_SAMPLE_CFLAGS = ' '.join(JAUDIO_BASE + JAUDIO_SAMPLE + LOCAL_CFLAGS) +JAUDIO_FUNC_ALIGN_32_CFLAGS = ' '.join(JAUDIO_BASE + JAUDIO_FUNC_ALIGN_32 + LOCAL_CFLAGS) DOL_LDFLAGS = ' '.join([ "-maxerrors 1", diff --git a/config/dol_slices.yml b/config/dol_slices.yml index f70a23e5..5136ef25 100644 --- a/config/dol_slices.yml +++ b/config/dol_slices.yml @@ -30,6 +30,12 @@ dvderr.c: .bss: [0x800e2790, 0x800e2b88] jaudio_NES/dummyprobe.c: .text: [0x800083f8, 0x80008400] +jaudio_NES/aictrl.c: + .text: [0x80017e80, 0x80018640] + .rodata: [0x800aa500, 0x800aa518] + .bss: [0x8017cfa0, 0x8017cfc0] + .sbss: [0x802183f0, 0x80218420] + .sdata2: [0x80218da8, 0x80218db8] jaudio_NES/sample.c: .text: [0x80018640, 0x80018920] # jaudio_NES/game64.c: # TODO: finish diff --git a/configure.py b/configure.py index 0956c5b1..04cc9feb 100644 --- a/configure.py +++ b/configure.py @@ -623,15 +623,20 @@ class AsmSource(Source): rule = "as", inputs = self.src_path ) - + +JAUDIO_FUNC_ALIGN_32_TUS = [ + "sample.c", + "aictrl.c" +] + class CSource(Source): def __init__(self, ctx: c.SourceContext, path: str): if path.startswith("src/static/dolphin/"): self.cflags = c.SDK_FLAGS self.cc = c.OCC elif path.startswith("src/static/jaudio_NES/"): - if path.startswith("src/static/jaudio_NES/sample.c"): - self.cflags = c.JAUDIO_SAMPLE_CFLAGS + if os.path.basename(path) in JAUDIO_FUNC_ALIGN_32_TUS: + self.cflags = c.JAUDIO_FUNC_ALIGN_32_CFLAGS else: self.cflags = c.JAUDIO_CFLAGS self.cc = c.CC diff --git a/include/dolphin/os.h b/include/dolphin/os.h index 7187662d..e925135d 100644 --- a/include/dolphin/os.h +++ b/include/dolphin/os.h @@ -2,6 +2,8 @@ #define _DOLPHIN_OS #include "types.h" +#include "dolphin/os/OSAlloc.h" +#include "dolphin/os/OSCache.h" #include "dolphin/os/OSContext.h" #include "dolphin/os/OSInterrupt.h" #include "dolphin/os/OSMessage.h" @@ -19,47 +21,46 @@ extern void __OSPSInit(); extern void __OSFPRInit(); extern void __OSCacheInit(); -void OSPanic(const char *file, int line, const char *message, ...); +void OSPanic(const char* file, int line, const char* message, ...); void OSVReport(const char* fmt, va_list list); void OSReport(const char* fmt, ...); extern void __OSPSInit(); extern void __OSCacheInit(); -#define OSErrorLine(line, ...) \ - OSPanic(__FILE__, line, __VA_ARGS__) +#define OSErrorLine(line, ...) OSPanic(__FILE__, line, __VA_ARGS__) #ifdef DOLPHIN_DEBUG -#define DOLPHIN_ASSERTLINE(assertion, line) \ - (void) ((assertion) || (OSErrorLine(line, "Failed assertion " #assertion), 0)) -#define DOLPHIN_ASSERT(assertion) \ - (void) ((assertion) || (OSPanic(__FILE__, __LINE__, "Failed assertion " #assertion), 0)) +#define DOLPHIN_ASSERTLINE(assertion, line) \ + (void)((assertion) || (OSErrorLine(line, "Failed assertion " #assertion), 0)) +#define DOLPHIN_ASSERT(assertion) \ + (void)((assertion) || (OSPanic(__FILE__, __LINE__, "Failed assertion " #assertion), 0)) #else #define DOLPHIN_ASSERTLINE(assertion, line) #define DOLPHIN_ASSERT(assertion) #endif -//void OSResetSystem(u32, u32, u32); // goes in reset, but eh +// void OSResetSystem(u32, u32, u32); // goes in reset, but eh void OSInit(void); -#define OS_CONSOLE_RETAIL4 0x00000004 -#define OS_CONSOLE_RETAIL3 0x00000003 -#define OS_CONSOLE_RETAIL2 0x00000002 -#define OS_CONSOLE_RETAIL1 0x00000001 -#define OS_CONSOLE_RETAIL 0x00000000 -#define OS_CONSOLE_DEVHW4 0x10000007 -#define OS_CONSOLE_DEVHW3 0x10000006 -#define OS_CONSOLE_DEVHW2 0x10000005 -#define OS_CONSOLE_DEVHW1 0x10000004 -#define OS_CONSOLE_MINNOW 0x10000003 -#define OS_CONSOLE_ARTHUR 0x10000002 +#define OS_CONSOLE_RETAIL4 0x00000004 +#define OS_CONSOLE_RETAIL3 0x00000003 +#define OS_CONSOLE_RETAIL2 0x00000002 +#define OS_CONSOLE_RETAIL1 0x00000001 +#define OS_CONSOLE_RETAIL 0x00000000 +#define OS_CONSOLE_DEVHW4 0x10000007 +#define OS_CONSOLE_DEVHW3 0x10000006 +#define OS_CONSOLE_DEVHW2 0x10000005 +#define OS_CONSOLE_DEVHW1 0x10000004 +#define OS_CONSOLE_MINNOW 0x10000003 +#define OS_CONSOLE_ARTHUR 0x10000002 #define OS_CONSOLE_PC_EMULATOR 0x10000001 -#define OS_CONSOLE_EMULATOR 0x10000000 +#define OS_CONSOLE_EMULATOR 0x10000000 #define OS_CONSOLE_DEVELOPMENT 0x10000000 -#define OS_CONSOLE_DEVKIT 0x10000000 -#define OS_CONSOLE_TDEVKIT 0x20000000 +#define OS_CONSOLE_DEVKIT 0x10000000 +#define OS_CONSOLE_TDEVKIT 0x20000000 -#define OS_CONSOLE_DEV_MASK 0x10000000 +#define OS_CONSOLE_DEV_MASK 0x10000000 u32 OSGetConsoleType(); #define OS_CONSOLE_IS_DEV() ((OSGetConsoleType() & OS_CONSOLE_DEV_MASK) != 0) diff --git a/include/dolphin/os/OSAlloc.h b/include/dolphin/os/OSAlloc.h index e413f67f..ae2f1cba 100644 --- a/include/dolphin/os/OSAlloc.h +++ b/include/dolphin/os/OSAlloc.h @@ -2,14 +2,31 @@ #define OS_ALLOC_H #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif - void *OSInitAlloc(void *, void *, int); +typedef int OSHeapHandle; + +extern volatile OSHeapHandle __OSCurrHeap; + +void* OSAllocFromHeap(int heap, unsigned long size); +void* OSAllocFixed(void* rstart, void* rend); +void OSFreeToHeap(int heap, void* ptr); +int OSSetCurrentHeap(int heap); +void* OSInitAlloc(void* arenaStart, void* arenaEnd, int maxHeaps); +int OSCreateHeap(void* start, void* end); +void OSDestroyHeap(int heap); +void OSAddToHeap(int heap, void* start, void* end); +long OSCheckHeap(int heap); +unsigned long OSReferentSize(void* ptr); +void OSDumpHeap(int heap); +void OSVisitAllocated(void (*visitor)(void*, unsigned long)); + +#define OSAlloc(size) OSAllocFromHeap(__OSCurrHeap, (size)) +#define OSFree(ptr) OSFreeToHeap(__OSCurrHeap, (ptr)) #ifdef __cplusplus } #endif -#endif \ No newline at end of file +#endif diff --git a/include/jaudio_NES/audiostruct.h b/include/jaudio_NES/audiostruct.h index 9a9f40f7..4e38a893 100644 --- a/include/jaudio_NES/audiostruct.h +++ b/include/jaudio_NES/audiostruct.h @@ -2,6 +2,7 @@ #define AUDIOSTRUCT_H #include "types.h" +#include "jaudio_NES/audiocommon.h" #ifdef __cplusplus extern "C" { diff --git a/include/jaudio_NES/dummyprobe.h b/include/jaudio_NES/dummyprobe.h index 6b155fef..f45d515d 100644 --- a/include/jaudio_NES/dummyprobe.h +++ b/include/jaudio_NES/dummyprobe.h @@ -7,11 +7,11 @@ extern "C" { #endif - void Probe_Start(void); - void Probe_Finish(void); +extern void Probe_Start(s32 id, const char* label); +extern void Probe_Finish(s32 id); #ifdef __cplusplus } #endif -#endif \ No newline at end of file +#endif diff --git a/src/static/jaudio_NES/dummyprobe.c b/src/static/jaudio_NES/dummyprobe.c index 1308e37e..f2ef6ff8 100644 --- a/src/static/jaudio_NES/dummyprobe.c +++ b/src/static/jaudio_NES/dummyprobe.c @@ -1,9 +1,7 @@ #include "jaudio_NES/dummyprobe.h" -void Probe_Start(void){ - +extern void Probe_Start(s32 id, const char* label) { } -void Probe_Finish(void){ - -} \ No newline at end of file +extern void Probe_Finish(s32 id) { +}