diff --git a/Makefile b/Makefile index 23490f8b9..b229b49ce 100644 --- a/Makefile +++ b/Makefile @@ -79,6 +79,11 @@ $(B_DIR)/lib/ultra/io/pfsgetstatus.o: LOOPUNROLL := $(B_DIR)/lib/ultra/libc/ll.o: MIPSISET := -mips3 -o32 $(B_DIR)/lib/ultra/libc/llcvt.o: MIPSISET := -mips3 -32 +# Note: Files that use -O3 must be compiled without the ASM processor, otherwise +# it introduces a race condition when using make -j because they create a +# temporary include-stdin.u file during compilation. +# For these files, see their explicit targets towards the end of this file. +$(B_DIR)/lib/ultra/audio/heap.o: OPT_LVL := -g $(B_DIR)/lib/ultra/gu/align.o: OPT_LVL := -O3 $(B_DIR)/lib/ultra/gu/frustum.o: OPT_LVL := -O3 $(B_DIR)/lib/ultra/gu/ortho.o: OPT_LVL := -O3 @@ -481,8 +486,8 @@ $(B_DIR)/assets/animations/list.o: $(A_DIR)/animations/list.c $(B_DIR)/lib/ultra/libc/llcvt.o: src/lib/ultra/libc/llcvt.c @mkdir -p $(dir $@) - /usr/bin/env python3 tools/asmpreproc/asm-processor.py -O2 $< | $(IDOCC) -c $(CFLAGS) tools/asmpreproc/include-stdin.c -o $@ - /usr/bin/env python3 tools/asmpreproc/asm-processor.py -O2 $< --post-process $@ --assembler "$(TOOLCHAIN)-as -march=vr4300 -mabi=32" --asm-prelude tools/asmpreproc/prelude.s + /usr/bin/env python3 tools/asmpreproc/asm-processor.py $(OPT_LVL) $< | $(IDOCC) -c $(CFLAGS) tools/asmpreproc/include-stdin.c -o $@ + /usr/bin/env python3 tools/asmpreproc/asm-processor.py $(OPT_LVL) $< --post-process $@ --assembler "$(TOOLCHAIN)-as -march=vr4300 -mabi=32" --asm-prelude tools/asmpreproc/prelude.s tools/patchmips3 $@ || rm $@ $(B_DIR)/lib/ultra/libc/ll.o: src/lib/ultra/libc/ll.c @@ -490,9 +495,10 @@ $(B_DIR)/lib/ultra/libc/ll.o: src/lib/ultra/libc/ll.c $(IDOCC) -c $(CFLAGS) $< -o $@ tools/patchmips3 $@ || rm $@ -# Files that use -O3 must be compiled without the ASM processor, otherwise it -# introduces a race condition when using make -j because they create a temporary -# include-stdin.u file during compilation. +$(B_DIR)/lib/ultra/gu/align.o: src/lib/ultra/gu/align.c + @mkdir -p $(dir $@) + $(IDOCC) -c $(CFLAGS) $< -o $@ + $(B_DIR)/lib/ultra/gu/frustum.o: src/lib/ultra/gu/frustum.c @mkdir -p $(dir $@) $(IDOCC) -c $(CFLAGS) $< -o $@ @@ -507,13 +513,13 @@ $(B_DIR)/lib/ultra/gu/scale.o: src/lib/ultra/gu/scale.c $(B_DIR)/lib/%.o: src/lib/%.c @mkdir -p $(dir $@) - /usr/bin/env python3 tools/asmpreproc/asm-processor.py -O2 $< | $(IDOCC) -c $(CFLAGS) tools/asmpreproc/include-stdin.c -o $@ - /usr/bin/env python3 tools/asmpreproc/asm-processor.py -O2 $< --post-process $@ --assembler "$(TOOLCHAIN)-as -march=vr4300 -mabi=32" --asm-prelude tools/asmpreproc/prelude.s + /usr/bin/env python3 tools/asmpreproc/asm-processor.py $(OPT_LVL) $< | $(IDOCC) -c $(CFLAGS) tools/asmpreproc/include-stdin.c -o $@ + /usr/bin/env python3 tools/asmpreproc/asm-processor.py $(OPT_LVL) $< --post-process $@ --assembler "$(TOOLCHAIN)-as -march=vr4300 -mabi=32" --asm-prelude tools/asmpreproc/prelude.s $(B_DIR)/game/%.o: src/game/%.c @mkdir -p $(dir $@) - /usr/bin/env python3 tools/asmpreproc/asm-processor.py -O2 $< | $(IDOCC) -c $(CFLAGS) tools/asmpreproc/include-stdin.c -o $@ - /usr/bin/env python3 tools/asmpreproc/asm-processor.py -O2 $< --post-process $@ --assembler "$(TOOLCHAIN)-as -march=vr4300 -mabi=32" --asm-prelude tools/asmpreproc/prelude.s + /usr/bin/env python3 tools/asmpreproc/asm-processor.py $(OPT_LVL) $< | $(IDOCC) -c $(CFLAGS) tools/asmpreproc/include-stdin.c -o $@ + /usr/bin/env python3 tools/asmpreproc/asm-processor.py $(OPT_LVL) $< --post-process $@ --assembler "$(TOOLCHAIN)-as -march=vr4300 -mabi=32" --asm-prelude tools/asmpreproc/prelude.s $(B_DIR)/%.o: src/%.c @mkdir -p $(dir $@) diff --git a/ld/libfiles.ntsc-beta.inc b/ld/libfiles.ntsc-beta.inc index d04d24228..f1bcc2c51 100644 --- a/ld/libfiles.ntsc-beta.inc +++ b/ld/libfiles.ntsc-beta.inc @@ -60,7 +60,7 @@ build/ROMID/lib/lib_2f490.o (section); \ build/ROMID/lib/lib_2f8a0.o (section); \ build/ROMID/lib/lib_2fa00.o (section); \ - build/ROMID/lib/lib_2faf0.o (section); \ + build/ROMID/lib/ultra/audio/heap.o (section); \ build/ROMID/lib/lib_2fba0.o (section); \ build/ROMID/lib/lib_2fc60.o (section); \ build/ROMID/lib/lib_30ce0.o (section); \ diff --git a/ld/libfiles.ntsc-final.inc b/ld/libfiles.ntsc-final.inc index 4c3e27d74..f17c5c386 100644 --- a/ld/libfiles.ntsc-final.inc +++ b/ld/libfiles.ntsc-final.inc @@ -58,7 +58,7 @@ build/ROMID/lib/lib_2f490.o (section); \ build/ROMID/lib/lib_2f8a0.o (section); \ build/ROMID/lib/lib_2fa00.o (section); \ - build/ROMID/lib/lib_2faf0.o (section); \ + build/ROMID/lib/ultra/audio/heap.o (section); \ build/ROMID/lib/lib_2fba0.o (section); \ build/ROMID/lib/lib_2fc60.o (section); \ build/ROMID/lib/lib_30ce0.o (section); \ diff --git a/ld/libfiles.pal-final.inc b/ld/libfiles.pal-final.inc index db6f6f8ae..9a013fe91 100644 --- a/ld/libfiles.pal-final.inc +++ b/ld/libfiles.pal-final.inc @@ -58,7 +58,7 @@ build/ROMID/lib/lib_2f490.o (section); \ build/ROMID/lib/lib_2f8a0.o (section); \ build/ROMID/lib/lib_2fa00.o (section); \ - build/ROMID/lib/lib_2faf0.o (section); \ + build/ROMID/lib/ultra/audio/heap.o (section); \ build/ROMID/lib/lib_2fba0.o (section); \ build/ROMID/lib/lib_2fc60.o (section); \ build/ROMID/lib/lib_30ce0.o (section); \ diff --git a/src/include/lib/lib_2faf0.h b/src/include/lib/lib_2faf0.h deleted file mode 100644 index 78c340321..000000000 --- a/src/include/lib/lib_2faf0.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _IN_LIB_LIB_2FAF0_H -#define _IN_LIB_LIB_2FAF0_H -#include -#include "data.h" -#include "types.h" - -#endif diff --git a/src/lib/audiomgr.c b/src/lib/audiomgr.c index 15f7ef359..04c5d717d 100644 --- a/src/lib/audiomgr.c +++ b/src/lib/audiomgr.c @@ -4,7 +4,6 @@ #include "constants.h" #include "bss.h" #include "lib/lib_09660.h" -#include "lib/lib_2faf0.h" #include "lib/lib_2fba0.h" #include "lib/lib_2fc60.h" #include "lib/lib_30ce0.h" diff --git a/src/lib/lib_09660.c b/src/lib/lib_09660.c index 0a97b887f..97ecd4c8b 100644 --- a/src/lib/lib_09660.c +++ b/src/lib/lib_09660.c @@ -9,7 +9,6 @@ #include "lib/lib_09660.h" #include "lib/memory.h" #include "lib/lib_159b0.h" -#include "lib/lib_2faf0.h" #include "lib/lib_30ce0.h" #include "lib/lib_4b170.h" #include "data.h" diff --git a/src/lib/lib_09a80.c b/src/lib/lib_09a80.c index 289cf65cd..60242d91e 100644 --- a/src/lib/lib_09a80.c +++ b/src/lib/lib_09a80.c @@ -10,7 +10,6 @@ #include "lib/lib_09660.h" #include "lib/memory.h" #include "lib/lib_159b0.h" -#include "lib/lib_2faf0.h" #include "lib/lib_30ce0.h" #include "lib/lib_4b170.h" #include "data.h" diff --git a/src/lib/lib_2faf0.c b/src/lib/lib_2faf0.c deleted file mode 100644 index f5544bfd7..000000000 --- a/src/lib/lib_2faf0.c +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include "constants.h" -#include "bss.h" -#include "data.h" -#include "types.h" - -GLOBAL_ASM( -glabel alHeapInit -/* 2faf0: ac850000 */ sw $a1,0x0($a0) -/* 2faf4: ac860008 */ sw $a2,0x8($a0) -/* 2faf8: 8c8e0000 */ lw $t6,0x0($a0) -/* 2fafc: ac8e0004 */ sw $t6,0x4($a0) -/* 2fb00: ac80000c */ sw $zero,0xc($a0) -/* 2fb04: 03e00008 */ jr $ra -/* 2fb08: 00000000 */ nop -/* 2fb0c: 03e00008 */ jr $ra -/* 2fb10: 00000000 */ nop -); - -GLOBAL_ASM( -glabel alHeapDBAlloc -/* 2fb14: 27bdfff8 */ addiu $sp,$sp,-8 -/* 2fb18: afa40008 */ sw $a0,0x8($sp) -/* 2fb1c: afa5000c */ sw $a1,0xc($sp) -/* 2fb20: afa00000 */ sw $zero,0x0($sp) -/* 2fb24: 8fae0018 */ lw $t6,0x18($sp) -/* 2fb28: 2401fff0 */ addiu $at,$zero,-16 -/* 2fb2c: 00ee0019 */ multu $a3,$t6 -/* 2fb30: 00007812 */ mflo $t7 -/* 2fb34: 25f8000f */ addiu $t8,$t7,0xf -/* 2fb38: 0301c824 */ and $t9,$t8,$at -/* 2fb3c: afb90004 */ sw $t9,0x4($sp) -/* 2fb40: 8cc80004 */ lw $t0,0x4($a2) -/* 2fb44: 8fa90004 */ lw $t1,0x4($sp) -/* 2fb48: 8ccb0000 */ lw $t3,0x0($a2) -/* 2fb4c: 8ccc0008 */ lw $t4,0x8($a2) -/* 2fb50: 01095021 */ addu $t2,$t0,$t1 -/* 2fb54: 016c6821 */ addu $t5,$t3,$t4 -/* 2fb58: 01aa082b */ sltu $at,$t5,$t2 -/* 2fb5c: 14200008 */ bnez $at,.L0002fb80 -/* 2fb60: 00000000 */ nop -/* 2fb64: 8cce0004 */ lw $t6,0x4($a2) -/* 2fb68: afae0000 */ sw $t6,0x0($sp) -/* 2fb6c: 8ccf0004 */ lw $t7,0x4($a2) -/* 2fb70: 8fb80004 */ lw $t8,0x4($sp) -/* 2fb74: 01f8c821 */ addu $t9,$t7,$t8 -/* 2fb78: 10000001 */ b .L0002fb80 -/* 2fb7c: acd90004 */ sw $t9,0x4($a2) -.L0002fb80: -/* 2fb80: 10000003 */ b .L0002fb90 -/* 2fb84: 8fa20000 */ lw $v0,0x0($sp) -/* 2fb88: 10000001 */ b .L0002fb90 -/* 2fb8c: 00000000 */ nop -.L0002fb90: -/* 2fb90: 03e00008 */ jr $ra -/* 2fb94: 27bd0008 */ addiu $sp,$sp,0x8 -); diff --git a/src/lib/lib_30ce0.c b/src/lib/lib_30ce0.c index d95515575..f6615ca4c 100644 --- a/src/lib/lib_30ce0.c +++ b/src/lib/lib_30ce0.c @@ -1,7 +1,6 @@ #include #include "constants.h" #include "bss.h" -#include "lib/lib_2faf0.h" #include "lib/lib_30ce0.h" #include "lib/lib_39fe0.h" #include "lib/lib_3a100.h" diff --git a/src/lib/lib_317f0.c b/src/lib/lib_317f0.c index c2a303546..b36d7779a 100644 --- a/src/lib/lib_317f0.c +++ b/src/lib/lib_317f0.c @@ -2,7 +2,6 @@ #include "constants.h" #include "bss.h" #include "lib/snd.h" -#include "lib/lib_2faf0.h" #include "lib/lib_2fc60.h" #include "lib/lib_30ce0.h" #include "lib/lib_317f0.h" diff --git a/src/lib/lib_34030.c b/src/lib/lib_34030.c index d794b6336..62ddb20c3 100644 --- a/src/lib/lib_34030.c +++ b/src/lib/lib_34030.c @@ -2,7 +2,6 @@ #include "constants.h" #include "bss.h" #include "lib/snd.h" -#include "lib/lib_2faf0.h" #include "lib/lib_2fc60.h" #include "lib/lib_30ce0.h" #include "lib/lib_317f0.h" diff --git a/src/lib/lib_34240.c b/src/lib/lib_34240.c index 19955bdbc..d34ec5fc5 100644 --- a/src/lib/lib_34240.c +++ b/src/lib/lib_34240.c @@ -2,7 +2,6 @@ #include "constants.h" #include "bss.h" #include "lib/snd.h" -#include "lib/lib_2faf0.h" #include "lib/lib_2fc60.h" #include "lib/lib_30ce0.h" #include "lib/lib_317f0.h" diff --git a/src/lib/lib_37b00.c b/src/lib/lib_37b00.c index d4c219d39..e8bcf12a2 100644 --- a/src/lib/lib_37b00.c +++ b/src/lib/lib_37b00.c @@ -1,7 +1,6 @@ #include #include "constants.h" #include "bss.h" -#include "lib/lib_2faf0.h" #include "lib/lib_37b00.h" #include "lib/lib_3e730.h" #include "lib/lib_43dd0.h" diff --git a/src/lib/lib_3a100.c b/src/lib/lib_3a100.c index 8b9c56a4f..e2b6bde49 100644 --- a/src/lib/lib_3a100.c +++ b/src/lib/lib_3a100.c @@ -2,7 +2,6 @@ #include "constants.h" #include "game/atan2f.h" #include "bss.h" -#include "lib/lib_2faf0.h" #include "lib/lib_3a100.h" #include "lib/lib_446d0.h" #include "data.h" diff --git a/src/lib/snd.c b/src/lib/snd.c index 6b55c19cd..9d4ad07ac 100644 --- a/src/lib/snd.c +++ b/src/lib/snd.c @@ -10,7 +10,6 @@ #include "lib/snd.h" #include "lib/memory.h" #include "lib/rng.h" -#include "lib/lib_2faf0.h" #include "lib/lib_2fc60.h" #include "lib/lib_317f0.h" #include "lib/lib_37650.h" diff --git a/src/lib/ultra/audio/heap.c b/src/lib/ultra/audio/heap.c new file mode 100644 index 000000000..31a070625 --- /dev/null +++ b/src/lib/ultra/audio/heap.c @@ -0,0 +1,30 @@ +#include +#include "constants.h" +#include "bss.h" +#include "data.h" +#include "types.h" + +void alHeapInit(ALHeap *hp, u8 *base, s32 len) +{ + hp->base = base; + hp->len = len; + hp->cur = hp->base; + hp->count = 0; +} + +void *alHeapDBAlloc(u8 *file, s32 line, ALHeap *hp, s32 num, s32 size) +{ + s32 bytes; + u8 *ptr = 0; + + bytes = (num * size + 0xf) & ~0xf; + + if (hp->cur + bytes <= hp->base + hp->len) { + ptr = hp->cur; + hp->cur += bytes; + } else { + + } + + return ptr; +}