From 34438419e52864ce4f51b5a05a33f8a2824c12f0 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Mon, 8 Mar 2021 12:18:53 +1000 Subject: [PATCH] Merge boot segment into lib --- Makefile | 12 +--- checksums.jpn-final.md5 | 3 +- checksums.ntsc-1.0.md5 | 3 +- checksums.ntsc-beta.md5 | 3 +- checksums.ntsc-final.md5 | 3 +- checksums.pal-beta.md5 | 3 +- checksums.pal-final.md5 | 3 +- ld/bootfiles.inc | 7 -- ld/libfiles.inc | 6 ++ ld/pd.ld | 33 ++-------- src/game/cheats.c | 2 +- src/game/chr/chr.c | 2 +- src/game/game_13c510.c | 2 +- src/game/game_176080.c | 2 +- src/include/{boot => lib}/entry.h | 0 src/include/{boot => lib}/init.h | 0 src/include/{boot => lib}/reset.h | 0 src/include/{boot => lib}/sched.h | 0 src/include/{boot => lib}/segments.h | 0 src/lib/audiomgr.c | 4 +- src/{boot => lib}/entry.c | 2 +- src/{boot => lib}/init.c | 8 +-- src/lib/lib_070d0.c | 2 +- src/lib/main.c | 2 +- src/{boot => lib}/reset.c | 95 +++++++++++++++++++++++++++- src/{boot => lib}/sched.c | 4 +- src/{boot => lib}/segments.s | 0 tools/extract | 9 ++- tools/packrom | 7 +- 29 files changed, 139 insertions(+), 78 deletions(-) delete mode 100644 ld/bootfiles.inc rename src/include/{boot => lib}/entry.h (100%) rename src/include/{boot => lib}/init.h (100%) rename src/include/{boot => lib}/reset.h (100%) rename src/include/{boot => lib}/sched.h (100%) rename src/include/{boot => lib}/segments.h (100%) rename src/{boot => lib}/entry.c (99%) rename src/{boot => lib}/init.c (99%) rename src/{boot => lib}/reset.c (56%) rename src/{boot => lib}/sched.c (99%) rename src/{boot => lib}/segments.s (100%) diff --git a/Makefile b/Makefile index 731bb6cd3..c50e1524f 100644 --- a/Makefile +++ b/Makefile @@ -126,8 +126,8 @@ CFLAGS = -DVERSION=$(VERSION) \ $(OPT_LVL) \ $(MIPSISET) -C_FILES := $(shell find src/gvars src/boot src/lib src/game src/inflate -name '*.c') -S_FILES := $(shell find src/boot src/lib src/game -name '*.s') +C_FILES := $(shell find src/gvars src/lib src/game src/inflate -name '*.c') +S_FILES := $(shell find src/lib src/game -name '*.s') # Create names such as $(B_DIR)/assets/files/PfooZ # These names (with .o added) will be dependenices for LD @@ -232,7 +232,6 @@ $(B_DIR)/pd.z64: $(B_DIR)/stage3.bin # stage 2, then extract-segment is used to slice out the segments. CHECK_FILES := \ - $(B_DIR)/segments/boot.bin \ $(B_DIR)/segments/filenames.bin \ $(B_DIR)/segments/firingrange.bin \ $(B_DIR)/segments/game.bin \ @@ -449,11 +448,6 @@ $(B_DIR)/assets/animations/list.o: src/assets/animations/list.c @mkdir -p $(dir $@) $(IDOCC) -c $(CFLAGS) $< -o $@ -$(B_DIR)/boot/%.o: src/boot/%.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 - $(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 $@ @@ -519,4 +513,4 @@ assetsclean: codeclean: rm -f $(B_DIR)/segments/*.bin - find $(B_DIR)/{boot,game,gvars,inflate,lib} -name '*.o' -delete + find $(B_DIR)/{game,gvars,inflate,lib} -name '*.o' -delete diff --git a/checksums.jpn-final.md5 b/checksums.jpn-final.md5 index a67e2f05d..844887000 100644 --- a/checksums.jpn-final.md5 +++ b/checksums.jpn-final.md5 @@ -2014,12 +2014,11 @@ f0068491f441172310f2b6868c03739d build/jpn-final/assets/files/bgdata/bg_wax_pad ea5a2ff4e5e0a68822f62feff2c40af4 build/jpn-final/assets/files/bgdata/bg_wax_tilesZ d41d8cd98f00b204e9800998ecf8427e build/jpn-final/assets/files/ob/ob_mid.seg 538d2b75945eae069b29c46193e74790 build/jpn-final/pd.z64 -39ef58f5babf5d619bec8b2629c26bc8 build/jpn-final/segments/boot.bin 333e8b4f6fe9dc9b59cf3e61b4e0c224 build/jpn-final/segments/firingrange.bin bd6e5fc360d5e0c35ea3605e2514f205 build/jpn-final/segments/game.bin 22d5e92bffcc67b222cf3697e96106f6 build/jpn-final/segments/data.bin 843285fdc0e80a77576eeb73940d2fd3 build/jpn-final/segments/inflate.bin -c550660ff4ba024113ddb38103bf79f8 build/jpn-final/segments/lib.bin +dd3b5fe7696544bb41e97cfae67fd431 build/jpn-final/segments/lib.bin c47d9377956666bc0e77d6cba3dc68fb build/jpn-final/segments/mpconfigs.bin 529b54a03375af2ff74eb3367cbac294 build/jpn-final/segments/mpstringsE.bin 4d1eb9e58e090aa91301917c518b5b5f build/jpn-final/segments/mpstringsF.bin diff --git a/checksums.ntsc-1.0.md5 b/checksums.ntsc-1.0.md5 index 7d33eabb0..32cb0d628 100644 --- a/checksums.ntsc-1.0.md5 +++ b/checksums.ntsc-1.0.md5 @@ -2012,12 +2012,11 @@ f0068491f441172310f2b6868c03739d build/ntsc-1.0/assets/files/bgdata/bg_wax_pads ea5a2ff4e5e0a68822f62feff2c40af4 build/ntsc-1.0/assets/files/bgdata/bg_wax_tilesZ d41d8cd98f00b204e9800998ecf8427e build/ntsc-1.0/assets/files/ob/ob_mid.seg 7f4171b0c8d17815be37913f535e4e93 build/ntsc-1.0/pd.z64 -402561223a33f48461e302e1cca12129 build/ntsc-1.0/segments/boot.bin cb373c94109322d081a57b142fdd9999 build/ntsc-1.0/segments/firingrange.bin 5181a0d11cf8f24370a3f2d3b29e522e build/ntsc-1.0/segments/game.bin b21679a1b2dabd721bc4afee11bf5266 build/ntsc-1.0/segments/data.bin 843285fdc0e80a77576eeb73940d2fd3 build/ntsc-1.0/segments/inflate.bin -3155eece856e9fbd9bc47d03463cfc1b build/ntsc-1.0/segments/lib.bin +0ee07d5d8e890e264e775e4034e3b900 build/ntsc-1.0/segments/lib.bin fe4034c01c91bd10e488fe93389b4104 build/ntsc-1.0/segments/mpconfigs.bin 529b54a03375af2ff74eb3367cbac294 build/ntsc-1.0/segments/mpstringsE.bin e4f45399a4f97e3fd6733f0f6919d28d build/ntsc-1.0/segments/mpstringsF.bin diff --git a/checksums.ntsc-beta.md5 b/checksums.ntsc-beta.md5 index 0fa5d71bf..2bb3db82b 100644 --- a/checksums.ntsc-beta.md5 +++ b/checksums.ntsc-beta.md5 @@ -2011,12 +2011,11 @@ c6f0dd6193685637763d426dfce837fb build/ntsc-beta/assets/files/bgdata/bg_wax_pad ea5a2ff4e5e0a68822f62feff2c40af4 build/ntsc-beta/assets/files/bgdata/bg_wax_tilesZ d41d8cd98f00b204e9800998ecf8427e build/ntsc-beta/assets/files/ob/ob_mid.seg aa93f4df16fceada399a749f5ad2f273 build/ntsc-beta/pd.z64 -74cb41628ed5784a8ad48c6398b0ce83 build/ntsc-beta/segments/boot.bin a12b5437510403bb09b3cceb45dd2a10 build/ntsc-beta/segments/firingrange.bin daae19f7ce11d3f3e1f98d543ad856f5 build/ntsc-beta/segments/game.bin cab47b8c30b1be608c1c5c1db08342de build/ntsc-beta/segments/data.bin d13f25c1c59fb96346ac23301ccd9d7d build/ntsc-beta/segments/inflate.bin -14aa42e2f0f215d931900d25ab70e576 build/ntsc-beta/segments/lib.bin +900199658b5cfb5a3c16844abc9da56e build/ntsc-beta/segments/lib.bin 8aaec8cc806ec62d2f70eaa08282e9c0 build/ntsc-beta/segments/mpconfigs.bin d52a0fc2e90e03b610879b50df4c0fd4 build/ntsc-beta/segments/mpstringsE.bin e4f45399a4f97e3fd6733f0f6919d28d build/ntsc-beta/segments/mpstringsF.bin diff --git a/checksums.ntsc-final.md5 b/checksums.ntsc-final.md5 index 7e0bad4cf..51146f3df 100644 --- a/checksums.ntsc-final.md5 +++ b/checksums.ntsc-final.md5 @@ -2012,12 +2012,11 @@ f0068491f441172310f2b6868c03739d build/ntsc-final/assets/files/bgdata/bg_wax_pa ea5a2ff4e5e0a68822f62feff2c40af4 build/ntsc-final/assets/files/bgdata/bg_wax_tilesZ d41d8cd98f00b204e9800998ecf8427e build/ntsc-final/assets/files/ob/ob_mid.seg e03b088b6ac9e0080440efed07c1e40f build/ntsc-final/pd.z64 -2a1aa1eff3cdfe5dc3e91a2e773a55b9 build/ntsc-final/segments/boot.bin cb373c94109322d081a57b142fdd9999 build/ntsc-final/segments/firingrange.bin ed0462324d1287de21611707172d316a build/ntsc-final/segments/game.bin 11c9c4c2737f66e7312949909b894dcc build/ntsc-final/segments/data.bin 843285fdc0e80a77576eeb73940d2fd3 build/ntsc-final/segments/inflate.bin -6a227624d708b43a10f220e005aef486 build/ntsc-final/segments/lib.bin +5ab66459c09843f5953718643c998625 build/ntsc-final/segments/lib.bin fe4034c01c91bd10e488fe93389b4104 build/ntsc-final/segments/mpconfigs.bin 529b54a03375af2ff74eb3367cbac294 build/ntsc-final/segments/mpstringsE.bin 302f7aa0464c781187551fcd3870aec2 build/ntsc-final/segments/mpstringsJ.bin diff --git a/checksums.pal-beta.md5 b/checksums.pal-beta.md5 index a9e14b8d1..c25e4ccd2 100644 --- a/checksums.pal-beta.md5 +++ b/checksums.pal-beta.md5 @@ -2012,12 +2012,11 @@ f0068491f441172310f2b6868c03739d build/pal-beta/assets/files/bgdata/bg_wax_pads ea5a2ff4e5e0a68822f62feff2c40af4 build/pal-beta/assets/files/bgdata/bg_wax_tilesZ d41d8cd98f00b204e9800998ecf8427e build/pal-beta/assets/files/ob/ob_mid.seg ad2de210a3455ba5ec541f0c78d91444 build/pal-beta/pd.z64 -541e374b58a36056f73ad02a2bbb5f75 build/pal-beta/segments/boot.bin 333e8b4f6fe9dc9b59cf3e61b4e0c224 build/pal-beta/segments/firingrange.bin ad5835b91b7e252ef8f4a421a44eb12b build/pal-beta/segments/game.bin bca5001a5dd0ef9aab24ba085f27eb40 build/pal-beta/segments/data.bin 843285fdc0e80a77576eeb73940d2fd3 build/pal-beta/segments/inflate.bin -7a859fcb6e89426543b5a207cc388f82 build/pal-beta/segments/lib.bin +317967a2f69b8e33ce588b0223ea3859 build/pal-beta/segments/lib.bin fe4034c01c91bd10e488fe93389b4104 build/pal-beta/segments/mpconfigs.bin 529b54a03375af2ff74eb3367cbac294 build/pal-beta/segments/mpstringsE.bin bed567631daf314f79ec8a2aa994f3a0 build/pal-beta/segments/mpstringsF.bin diff --git a/checksums.pal-final.md5 b/checksums.pal-final.md5 index 42a47133f..ec4e08a19 100644 --- a/checksums.pal-final.md5 +++ b/checksums.pal-final.md5 @@ -2012,12 +2012,11 @@ f0068491f441172310f2b6868c03739d build/pal-final/assets/files/bgdata/bg_wax_pad ea5a2ff4e5e0a68822f62feff2c40af4 build/pal-final/assets/files/bgdata/bg_wax_tilesZ d41d8cd98f00b204e9800998ecf8427e build/pal-final/assets/files/ob/ob_mid.seg d9b5cd305d228424891ce38e71bc9213 build/pal-final/pd.z64 -7c4233976802db99f90c6c0fede1080b build/pal-final/segments/boot.bin 333e8b4f6fe9dc9b59cf3e61b4e0c224 build/pal-final/segments/firingrange.bin 4e506821044251aecc10ec332389c576 build/pal-final/segments/game.bin 1c49c171e829a5407f0ae5fd28a123cd build/pal-final/segments/data.bin 843285fdc0e80a77576eeb73940d2fd3 build/pal-final/segments/inflate.bin -b83973db626573e024608444e5d74461 build/pal-final/segments/lib.bin +ba4edc92cda812aaddff2810be77dbf7 build/pal-final/segments/lib.bin 7f5540dd6fff2039b2ce05bf57ac5611 build/pal-final/segments/mpconfigs.bin 529b54a03375af2ff74eb3367cbac294 build/pal-final/segments/mpstringsE.bin 4d1eb9e58e090aa91301917c518b5b5f build/pal-final/segments/mpstringsF.bin diff --git a/ld/bootfiles.inc b/ld/bootfiles.inc deleted file mode 100644 index 8b74382f4..000000000 --- a/ld/bootfiles.inc +++ /dev/null @@ -1,7 +0,0 @@ -#define BOOTFILES(section) \ - build/ROMID/boot/entry.o (section); \ - build/ROMID/boot/segments.o (section); \ - build/ROMID/boot/init.o (section); \ - build/ROMID/boot/sched.o (section); \ - build/ROMID/boot/reset.o (section); \ - build/ROMID/lib/ultra/os/maptlbrdb.o (section); diff --git a/ld/libfiles.inc b/ld/libfiles.inc index 137876fdc..6e0b7e82c 100644 --- a/ld/libfiles.inc +++ b/ld/libfiles.inc @@ -1,4 +1,10 @@ #define LIBFILES(section) \ + build/ROMID/lib/entry.o (section); \ + build/ROMID/lib/segments.o (section); \ + build/ROMID/lib/init.o (section); \ + build/ROMID/lib/sched.o (section); \ + build/ROMID/lib/reset.o (section); \ + build/ROMID/lib/ultra/os/maptlbrdb.o (section); \ build/ROMID/game/data/data_000000.o (section); \ build/ROMID/lib/ultra/io/vimgr.o (section); \ build/ROMID/lib/ultra/io/pimgr.o (section); \ diff --git a/ld/pd.ld b/ld/pd.ld index be042bd1f..8d980be8b 100644 --- a/ld/pd.ld +++ b/ld/pd.ld @@ -1,4 +1,3 @@ -#include "bootfiles.inc" #include "gamefiles.inc" #include "libfiles.inc" @@ -77,7 +76,7 @@ * increased. */ -#define ROMALLOCATION_LIB 0x036800 +#define ROMALLOCATION_LIB 0x038850 #define ROMALLOCATION_DATA 0x015000 #define ROMALLOCATION_GAME 0x151980 @@ -180,46 +179,28 @@ SECTIONS } END_SEG(bootloader) - /*************************************************************************** - * boot - * ------------------------------------------------------------------------- - * ROM range: 0x00001000 - 0x00003050 - * RAM range: 0x70001000 - 0x70003050 - * ------------------------------------------------------------------------- - */ - - __rampos = 0x70001000; - - BEGIN_SEG(boot) - { - BOOTFILES(.text) - } - END_SEG(boot) - - _bootSegmentStart = 0x70001050; - /*************************************************************************** * lib * ------------------------------------------------------------------------- - * ROM range: 0x00003050 - 0x00039850 (compressed) - * RAM range: 0x70003050 - 0x70059fe0 + * ROM range: 0x00001000 - 0x00039850 (compressed from 0x3050 onwards) + * RAM range: 0x70001000 - 0x70059fe0 * ------------------------------------------------------------------------- - * This compressed segment must be placed immediately after boot, because - * the boot code calculates the lib address as boot start + boot length. */ PLACEHOLDER_SEGMENT(libzip) __rompos = 0x02000000; + __rampos = 0x70001000; BEGIN_SEG(lib) { LIBFILES(.text) - BOOTFILES(.rodata) LIBFILES(.rodata) } END_SEG(lib) + _libSegmentStart = 0x70001050; + /*************************************************************************** * data * ------------------------------------------------------------------------- @@ -235,7 +216,7 @@ SECTIONS PLACEHOLDER_SEGMENT(datazip) __rompos = __savedrompos; - __rampos = 0x80001000 + SIZEOF(.boot) + SIZEOF(.lib); + __rampos = 0x80001000 + SIZEOF(.lib); BEGIN_SEG(data) { diff --git a/src/game/cheats.c b/src/game/cheats.c index bf9f27e53..675896eb4 100644 --- a/src/game/cheats.c +++ b/src/game/cheats.c @@ -1,6 +1,6 @@ #include #include "constants.h" -#include "boot/sched.h" +#include "lib/sched.h" #include "game/camdraw.h" #include "game/cheats.h" #include "game/inventory/inventory.h" diff --git a/src/game/chr/chr.c b/src/game/chr/chr.c index 6d66c376e..37e2fe629 100644 --- a/src/game/chr/chr.c +++ b/src/game/chr/chr.c @@ -1,5 +1,5 @@ #include -#include "boot/sched.h" +#include "lib/sched.h" #include "constants.h" #include "game/bondmove.h" #include "game/cheats.h" diff --git a/src/game/game_13c510.c b/src/game/game_13c510.c index f858bcdff..a72054bcd 100644 --- a/src/game/game_13c510.c +++ b/src/game/game_13c510.c @@ -1,5 +1,5 @@ #include -#include "boot/sched.h" +#include "lib/sched.h" #include "constants.h" #include "game/dlights.h" #include "game/game_0b2150.h" diff --git a/src/game/game_176080.c b/src/game/game_176080.c index 15622c26a..2e4b4a746 100644 --- a/src/game/game_176080.c +++ b/src/game/game_176080.c @@ -1,6 +1,6 @@ #include #include "constants.h" -#include "boot/sched.h" +#include "lib/sched.h" #include "game/game_0b69d0.h" #include "game/game_176080.h" #include "game/mplayer/mplayer.h" diff --git a/src/include/boot/entry.h b/src/include/lib/entry.h similarity index 100% rename from src/include/boot/entry.h rename to src/include/lib/entry.h diff --git a/src/include/boot/init.h b/src/include/lib/init.h similarity index 100% rename from src/include/boot/init.h rename to src/include/lib/init.h diff --git a/src/include/boot/reset.h b/src/include/lib/reset.h similarity index 100% rename from src/include/boot/reset.h rename to src/include/lib/reset.h diff --git a/src/include/boot/sched.h b/src/include/lib/sched.h similarity index 100% rename from src/include/boot/sched.h rename to src/include/lib/sched.h diff --git a/src/include/boot/segments.h b/src/include/lib/segments.h similarity index 100% rename from src/include/boot/segments.h rename to src/include/lib/segments.h diff --git a/src/lib/audiomgr.c b/src/lib/audiomgr.c index 3d8a539da..02fea62ea 100644 --- a/src/lib/audiomgr.c +++ b/src/lib/audiomgr.c @@ -1,6 +1,6 @@ #include -#include "boot/init.h" -#include "boot/sched.h" +#include "lib/init.h" +#include "lib/sched.h" #include "constants.h" #include "gvars/gvars.h" #include "lib/lib_09660.h" diff --git a/src/boot/entry.c b/src/lib/entry.c similarity index 99% rename from src/boot/entry.c rename to src/lib/entry.c index 0ca4d9707..7e9ee5a10 100644 --- a/src/boot/entry.c +++ b/src/lib/entry.c @@ -1,5 +1,5 @@ #include -#include "boot/entry.h" +#include "lib/entry.h" #include "constants.h" #include "game/game_0e0770.h" #include "gvars/gvars.h" diff --git a/src/boot/init.c b/src/lib/init.c similarity index 99% rename from src/boot/init.c rename to src/lib/init.c index 52fe7533a..1b4a9dcf8 100644 --- a/src/boot/init.c +++ b/src/lib/init.c @@ -1,8 +1,8 @@ #include -#include "boot/entry.h" -#include "boot/init.h" -#include "boot/reset.h" -#include "boot/segments.h" +#include "lib/entry.h" +#include "lib/init.h" +#include "lib/reset.h" +#include "lib/segments.h" #include "constants.h" #include "game/game_0e0770.h" #include "gvars/gvars.h" diff --git a/src/lib/lib_070d0.c b/src/lib/lib_070d0.c index e2d05dd27..4f7fd33c4 100644 --- a/src/lib/lib_070d0.c +++ b/src/lib/lib_070d0.c @@ -1,5 +1,5 @@ #include -#include "boot/entry.h" +#include "lib/entry.h" #include "constants.h" #include "gvars/gvars.h" #include "lib/lib_074f0.h" diff --git a/src/lib/main.c b/src/lib/main.c index beeff1ffe..4ff3852f0 100644 --- a/src/lib/main.c +++ b/src/lib/main.c @@ -1,5 +1,5 @@ #include -#include "boot/sched.h" +#include "lib/sched.h" #include "constants.h" #include "game/camdraw.h" #include "game/cheats.h" diff --git a/src/boot/reset.c b/src/lib/reset.c similarity index 56% rename from src/boot/reset.c rename to src/lib/reset.c index c0c31e1eb..51ca50429 100644 --- a/src/boot/reset.c +++ b/src/lib/reset.c @@ -1,10 +1,102 @@ #include #include "constants.h" -#include "boot/reset.h" +#include "lib/reset.h" #include "gvars/gvars.h" #include "data.h" #include "types.h" +#if VERSION >= VERSION_PAL_FINAL +GLOBAL_ASM( +glabel resetproc +/* 2df0: 27bdffd0 */ addiu $sp,$sp,-48 +/* 2df4: afa40030 */ sw $a0,0x30($sp) +/* 2df8: afbf0014 */ sw $ra,0x14($sp) +/* 2dfc: 3c048009 */ lui $a0,0x8009 +/* 2e00: afa0002c */ sw $zero,0x2c($sp) +/* 2e04: 2484fff8 */ addiu $a0,$a0,-8 +/* 2e08: 27a5002c */ addiu $a1,$sp,0x2c +/* 2e0c: 0c011ffc */ jal 0x47ff0 +/* 2e10: 24060001 */ li $a2,0x1 +/* 2e14: 240e0001 */ li $t6,0x1 +/* 2e18: 3c018006 */ lui $at,0x8006 +/* 2e1c: 0c002413 */ jal 0x904c +/* 2e20: a02ecb80 */ sb $t6,-0x3480($at) +/* 2e24: 3c048009 */ lui $a0,0x8009 +/* 2e28: 0c011f1c */ jal 0x47c70 +/* 2e2c: 2484dc20 */ addiu $a0,$a0,-9184 +/* 2e30: 00002025 */ move $a0,$zero +/* 2e34: 0c011f4c */ jal 0x47d30 +/* 2e38: 2405000b */ li $a1,0xb +/* 2e3c: 3c028006 */ lui $v0,0x8006 +/* 2e40: 2442f3c0 */ addiu $v0,$v0,-3136 +/* 2e44: 24030400 */ li $v1,0x400 +/* 2e48: 3c048006 */ lui $a0,0x8006 +/* 2e4c: ac43052c */ sw $v1,0x52c($v0) +/* 2e50: ac430540 */ sw $v1,0x540($v0) +/* 2e54: 0c012194 */ jal 0x48650 +/* 2e58: 2484f8c0 */ addiu $a0,$a0,-1856 +/* 2e5c: 0c012178 */ jal 0x485e0 +/* 2e60: 24040001 */ li $a0,0x1 +/* 2e64: 0c012288 */ jal 0x48a20 +/* 2e68: 00000000 */ nop +/* 2e6c: 3c018009 */ lui $at,0x8009 +/* 2e70: ac220340 */ sw $v0,0x340($at) +/* 2e74: 0c012288 */ jal 0x48a20 +/* 2e78: ac230344 */ sw $v1,0x344($at) +/* 2e7c: 3c198009 */ lui $t9,0x8009 +/* 2e80: 8f390344 */ lw $t9,0x344($t9) +/* 2e84: 3c188009 */ lui $t8,0x8009 +/* 2e88: 3c010022 */ lui $at,0x22 +/* 2e8c: 8f180340 */ lw $t8,0x340($t8) +/* 2e90: 3421add7 */ ori $at,$at,0xadd7 +/* 2e94: 03214821 */ addu $t1,$t9,$at +/* 2e98: 0121082b */ sltu $at,$t1,$at +/* 2e9c: 03014021 */ addu $t0,$t8,$at +/* 2ea0: 25080000 */ addiu $t0,$t0,0x0 +/* 2ea4: 0102082b */ sltu $at,$t0,$v0 +/* 2ea8: 14200019 */ bnez $at,.PF00002f10 +/* 2eac: 0048082b */ sltu $at,$v0,$t0 +/* 2eb0: 14200003 */ bnez $at,.PF00002ec0 +/* 2eb4: 0069082b */ sltu $at,$v1,$t1 +/* 2eb8: 10200015 */ beqz $at,.PF00002f10 +/* 2ebc: 00000000 */ nop +.PF00002ec0: +/* 2ec0: 0c012288 */ jal 0x48a20 +/* 2ec4: 00000000 */ nop +/* 2ec8: 3c0b8009 */ lui $t3,0x8009 +/* 2ecc: 8d6b0344 */ lw $t3,0x344($t3) +/* 2ed0: 3c0a8009 */ lui $t2,0x8009 +/* 2ed4: 3c010022 */ lui $at,0x22 +/* 2ed8: 8d4a0340 */ lw $t2,0x340($t2) +/* 2edc: 3421add7 */ ori $at,$at,0xadd7 +/* 2ee0: 01616821 */ addu $t5,$t3,$at +/* 2ee4: 01a1082b */ sltu $at,$t5,$at +/* 2ee8: 01416021 */ addu $t4,$t2,$at +/* 2eec: 258c0000 */ addiu $t4,$t4,0x0 +/* 2ef0: 004c082b */ sltu $at,$v0,$t4 +/* 2ef4: 1420fff2 */ bnez $at,.PF00002ec0 +/* 2ef8: 00000000 */ nop +/* 2efc: 0182082b */ sltu $at,$t4,$v0 +/* 2f00: 14200003 */ bnez $at,.PF00002f10 +/* 2f04: 006d082b */ sltu $at,$v1,$t5 +/* 2f08: 1420ffed */ bnez $at,.PF00002ec0 +/* 2f0c: 00000000 */ nop +.PF00002f10: +/* 2f10: 0c0053c9 */ jal 0x14f24 +/* 2f14: 00000000 */ nop +.PF00002f18: +/* 2f18: 1000ffff */ b .PF00002f18 +/* 2f1c: 00000000 */ nop +/* 2f20: 00000000 */ nop +/* 2f24: 00000000 */ nop +/* 2f28: 00000000 */ nop +/* 2f2c: 00000000 */ nop +/* 2f30: 8fbf0014 */ lw $ra,0x14($sp) +/* 2f34: 27bd0030 */ addiu $sp,$sp,0x30 +/* 2f38: 03e00008 */ jr $ra +/* 2f3c: 00000000 */ nop +); +#else GLOBAL_ASM( glabel resetproc /* 2e00: 27bdffd0 */ addiu $sp,$sp,-48 @@ -105,6 +197,7 @@ glabel resetproc /* 2f68: 03e00008 */ jr $ra /* 2f6c: 00000000 */ nop ); +#endif void resetThreadCreate(void) { diff --git a/src/boot/sched.c b/src/lib/sched.c similarity index 99% rename from src/boot/sched.c rename to src/lib/sched.c index b5b06cefd..e645295a1 100644 --- a/src/boot/sched.c +++ b/src/lib/sched.c @@ -1,6 +1,6 @@ #include -#include "boot/init.h" -#include "boot/sched.h" +#include "lib/init.h" +#include "lib/sched.h" #include "constants.h" #include "game/game_0e0770.h" #include "gvars/gvars.h" diff --git a/src/boot/segments.s b/src/lib/segments.s similarity index 100% rename from src/boot/segments.s rename to src/lib/segments.s diff --git a/tools/extract b/tools/extract index e77f9f7d8..57c7334db 100755 --- a/tools/extract +++ b/tools/extract @@ -19,7 +19,6 @@ class Extractor: self.extract_accessingpak() self.extract_animations() self.extract_audio() - self.extract_boot() self.extract_bootloader() self.extract_copyright() self.extract_data() @@ -89,9 +88,6 @@ class Extractor: offset = int.from_bytes(sequences[pos:pos+4], 'big') return self.decompress(sequences[offset:]) - def extract_boot(self): - self.write_extracted('segments/boot.bin', self.rom[0x1000:0x3050]) - def extract_copyright(self): addr = self.val('copyright') data = self.decompress(self.rom[addr:addr+0xb30]) @@ -201,8 +197,11 @@ class Extractor: end = self.val('animations') self.write_asset('garbage/%s/garbage2.bin' % self.romid, self.rom[start:end]) + # In all versions, lib starts at 0x1000 and is compressed from 0x3050 onwards def extract_lib(self): - self.write_extracted('segments/lib.bin', self.decompress(self.rom[0x3050:])) + part1 = self.rom[0x1000:0x3050] + part2 = self.decompress(self.rom[0x3050:]) + self.write_extracted('segments/lib.bin', part1 + part2) def extract_mpconfigs(self): addr = self.val('mpconfigs') diff --git a/tools/packrom b/tools/packrom index 4ad8db316..7d418f2d7 100755 --- a/tools/packrom +++ b/tools/packrom @@ -68,9 +68,10 @@ def get_segment(fd, locations, segname): fd.seek(start) return fd.read(end - start) +# lib is compressed from offset 0x2050 onwards def pack_lib(fd, locations): lib = get_segment(fd, locations, 'lib') - zipped = zip(lib) + zipped = lib[0:0x2050] + zip(lib[0x2050:]) attempt(fd, locations, 'lib', zipped, 'ROMALLOCATION_LIB') def pack_data(fd, locations): @@ -105,7 +106,7 @@ def write_garbage_part(fd, addr, filename): fd.seek(addr) fd.write(binary) -def write_garbage(fd, locations): +def write_garbage(fd): if os.environ['ROMID'] == 'ntsc-final': write_garbage_part(fd, 0x2ea6c, 'garbage1.bin') write_garbage_part(fd, 0x157800, 'garbage2.bin') @@ -132,7 +133,7 @@ def main(): fd = open(sys.argv[1], 'rb+') - write_garbage(fd, locations) + write_garbage(fd) pack_lib(fd, locations) pack_data(fd, locations)