1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-14 05:19:36 +00:00
* libu64

* logutils.o -> debug.o in spec

* stackcheck.c is part of libu64

* review

* add paragraph about Overlay_Load calling an external function

* audio code*
This commit is contained in:
Dragorn421 2024-11-01 23:47:12 +01:00 committed by GitHub
parent 012c192f00
commit 5b27899b9f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 97 additions and 29 deletions

View file

@ -443,20 +443,9 @@ endif
ifeq ($(COMPILER),ido)
$(BUILD_DIR)/src/boot/driverominit.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/boot/logutils.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/boot/stackcheck.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/code_800FC620.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/gfxprint.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/jpegutils.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/jpegdecoder.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/loadfragment2_n64.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/load_gc.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/loadfragment2_gc.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/mtxuty-cvt.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/padsetup.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/padutils.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/relocation_gc.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/fault_n64.o: CFLAGS += -trapuv
$(BUILD_DIR)/src/code/fault_gc.o: CFLAGS += -trapuv
@ -481,6 +470,8 @@ endif
$(BUILD_DIR)/src/libc64/%.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libu64/%.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/audio/%.o: OPTFLAGS := -O2
# Use signed chars instead of unsigned for this audio file (needed to match AudioDebug_ScrPrt)

77
docs/libu64.md Normal file
View file

@ -0,0 +1,77 @@
# libu64
This document explains the reasoning behind organizing the libu64 files.
libu64 is known about from the Animal Crossing (GameCube) map files.
Here is the relevant excerpt from the Doubutsu no Mori+ 1.0 map file (for .text):
```
00057f00 00043c 8005d4c0 1 .text libu64.a debug.c
UNUSED 000070 ........ f_debug_range_f libu64.a debug.c
UNUSED 00007c ........ _dbg_range libu64.a debug.c
UNUSED 000158 ........ _dbg_dump libu64.a debug.c
UNUSED 000048 ........ _dbg_array_error libu64.a debug.c
UNUSED 000054 ........ _dbg_bound libu64.a debug.c
UNUSED 000044 ........ _dbg_null libu64.a debug.c
UNUSED 000060 ........ _dbg_ptr libu64.a debug.c
UNUSED 000058 ........ _dbg_here libu64.a debug.c
00057f00 00005c 8005d4c0 4 _dbg_hungup libu64.a debug.c
UNUSED 000004 ........ Reset libu64.a debug.c
00057f5c 000b70 8005d51c 1 .text libu64.a gfxprint.c
00057f5c 0002e8 8005d51c 4 gfxprint_setup libu64.a gfxprint.c
00058244 00004c 8005d804 4 gfxprint_color libu64.a gfxprint.c
UNUSED 000024 ........ gfxprint_locate libu64.a gfxprint.c
00058290 000024 8005d850 4 gfxprint_locate8x8 libu64.a gfxprint.c
UNUSED 000014 ........ gfxprint_setoffset libu64.a gfxprint.c
000582b4 000378 8005d874 4 gfxprint_putc1 libu64.a gfxprint.c
0005862c 000198 8005dbec 4 gfxprint_putc libu64.a gfxprint.c
UNUSED 000060 ........ gfxprint_write libu64.a gfxprint.c
UNUSED 000054 ........ gfxprint_puts libu64.a gfxprint.c
000587c4 000064 8005dd84 4 gfxprint_prout libu64.a gfxprint.c
00058828 000090 8005dde8 4 gfxprint_init libu64.a gfxprint.c
000588b8 000004 8005de78 4 gfxprint_cleanup libu64.a gfxprint.c
000588bc 00004c 8005de7c 4 gfxprint_open libu64.a gfxprint.c
00058908 000038 8005dec8 4 gfxprint_close libu64.a gfxprint.c
UNUSED 000020 ........ gfxprint_vprintf libu64.a gfxprint.c
00058940 000080 8005df00 4 gfxprint_printf libu64.a gfxprint.c
000589c0 000000 8005df80 1 .text libu64.a gfxprint_data.c
000589c0 000164 8005df80 1 .text libu64.a pad.c
UNUSED 000024 ........ pad_init libu64.a pad.c
UNUSED 000004 ........ pad_cleanup libu64.a pad.c
UNUSED 000010 ........ pad_flush libu64.a pad.c
UNUSED 000018 ........ pad_push_only libu64.a pad.c
UNUSED 00001c ........ pad_push_also libu64.a pad.c
UNUSED 00001c ........ pad_on_trigger libu64.a pad.c
UNUSED 00001c ........ pad_off_trigger libu64.a pad.c
UNUSED 000008 ........ pad_button libu64.a pad.c
UNUSED 000008 ........ pad_trigger libu64.a pad.c
UNUSED 00000c ........ pad_physical_stick_x libu64.a pad.c
UNUSED 00000c ........ pad_physical_stick_y libu64.a pad.c
UNUSED 000014 ........ pad_set_logical_stick libu64.a pad.c
UNUSED 00000c ........ pad_logical_stick_x libu64.a pad.c
UNUSED 00000c ........ pad_logical_stick_y libu64.a pad.c
UNUSED 00000c ........ pad_stick_x libu64.a pad.c
UNUSED 00000c ........ pad_stick_y libu64.a pad.c
000589c0 000054 8005df80 4 pad_correct_stick libu64.a pad.c
```
This repository's `debug.c` (formerly `logutils.c`), `gfxprint.c` and `pad.c` (formerly `padutils.c`) line up with the map.
Note `debug.c` has additional debug-only functions in gc-eu-mq-dbg, hinting that there were two versions of libu64, a debug version and a non-debug version.
Additionally `debug.c`, `gfxprint.c` and `pad.c` all require compilation flags `-O2` (instead of `-O2 -g3`) to match, as supplementary evidence these were part of a separately compiled library.
`-O2` is also required for most files between `gfxprint.c` and `pad.c` in the code segment (see spec), hinting that these other files (`loadfragment2_n64.c`, `loadfragment2_gc.c`, `mtxuty-cvt.c`, `relocation_gc.c`, `load_gc.c`, `code_800FC620.c`) are also part of libu64.
Files `rcp_utils.c` and `logseverity_gc.c` do not strictly require `-O2`, but they do match with `-O2`.
`padsetup.c` also requires `-O2`.
On the other hand, the function `Overlay_Load` (in `loadfragment2_n64.c` or `load_gc.c` depending on game version) calls `DmaMgr_RequestSync`, a function that is not part of libu64.
This could suggest these files are not part of libu64, but the other evidence detailed above seems stronger.
It is also a possibility that libu64 expected users to provide the function, and it would have been an undefined symbol in the library.
All in all this suggests all files in code between the audio code and libc64, are part of libu64.
In the OoT boot segment, `stackcheck.c` is right next to `debug.c` and requires `-O2`: this hints `stackcheck.c` could be part of libu64 too. This is confirmed by looking at Majora's Mask n64-us, where `stackcheck.c` is in the middle of other libu64 files in the boot segment (see MM spec).

36
spec
View file

@ -32,8 +32,8 @@ beginseg
include "$(BUILD_DIR)/src/boot/is_debug.o"
include "$(BUILD_DIR)/src/boot/driverominit.o"
include "$(BUILD_DIR)/src/boot/mio0.o"
include "$(BUILD_DIR)/src/boot/stackcheck.o"
include "$(BUILD_DIR)/src/boot/logutils.o"
include "$(BUILD_DIR)/src/libu64/stackcheck.o"
include "$(BUILD_DIR)/src/libu64/debug.o"
#if PLATFORM_N64
include "$(BUILD_DIR)/src/libc64/sleep.o"
#endif
@ -736,25 +736,25 @@ beginseg
include "$(BUILD_DIR)/src/audio/data.o"
include "$(BUILD_DIR)/src/audio/session_config.o"
#if PLATFORM_N64
include "$(BUILD_DIR)/src/code/gfxprint.o"
include "$(BUILD_DIR)/src/code/rcp_utils.o"
include "$(BUILD_DIR)/src/code/loadfragment2_n64.o"
include "$(BUILD_DIR)/src/code/padutils.o"
include "$(BUILD_DIR)/src/code/code_800FC620.o"
include "$(BUILD_DIR)/src/code/padsetup.o"
include "$(BUILD_DIR)/src/libu64/gfxprint.o"
include "$(BUILD_DIR)/src/libu64/rcp_utils.o"
include "$(BUILD_DIR)/src/libu64/loadfragment2_n64.o"
include "$(BUILD_DIR)/src/libu64/pad.o"
include "$(BUILD_DIR)/src/libu64/code_800FC620.o"
include "$(BUILD_DIR)/src/libu64/padsetup.o"
#else
include "$(BUILD_DIR)/src/code/logseverity_gc.o"
include "$(BUILD_DIR)/src/code/gfxprint.o"
include "$(BUILD_DIR)/src/code/rcp_utils.o"
include "$(BUILD_DIR)/src/code/loadfragment2_gc.o"
include "$(BUILD_DIR)/src/libu64/logseverity_gc.o"
include "$(BUILD_DIR)/src/libu64/gfxprint.o"
include "$(BUILD_DIR)/src/libu64/rcp_utils.o"
include "$(BUILD_DIR)/src/libu64/loadfragment2_gc.o"
#if OOT_DEBUG
include "$(BUILD_DIR)/src/code/mtxuty-cvt.o"
include "$(BUILD_DIR)/src/libu64/mtxuty-cvt.o"
#endif
include "$(BUILD_DIR)/src/code/relocation_gc.o"
include "$(BUILD_DIR)/src/code/load_gc.o"
include "$(BUILD_DIR)/src/code/code_800FC620.o"
include "$(BUILD_DIR)/src/code/padutils.o"
include "$(BUILD_DIR)/src/code/padsetup.o"
include "$(BUILD_DIR)/src/libu64/relocation_gc.o"
include "$(BUILD_DIR)/src/libu64/load_gc.o"
include "$(BUILD_DIR)/src/libu64/code_800FC620.o"
include "$(BUILD_DIR)/src/libu64/pad.o"
include "$(BUILD_DIR)/src/libu64/padsetup.o"
#endif
include "$(BUILD_DIR)/src/libc64/math64.o"
include "$(BUILD_DIR)/src/libc64/fp.o"