mirror of
https://github.com/n64decomp/perfect_dark.git
synced 2024-11-23 13:59:42 +00:00
Make ROM great again (aka matching)
This commit is contained in:
parent
946d22a6ae
commit
1330bae0ee
20
Makefile
20
Makefile
@ -13,14 +13,14 @@ B_DIR := build/$(ROMID)
|
||||
QEMU_IRIX := tools/irix/qemu-irix
|
||||
IRIX_ROOT := tools/irix/root
|
||||
|
||||
ifeq ($(shell type mips-linux-gnu-ld >/dev/null 2>/dev/null; echo $$?), 0)
|
||||
ifeq ($(shell type mips64-elf-ld >/dev/null 2>/dev/null; echo $$?), 0)
|
||||
TOOLCHAIN := mips64-elf
|
||||
else ifeq ($(shell type mips-linux-gnu-ld >/dev/null 2>/dev/null; echo $$?), 0)
|
||||
TOOLCHAIN := mips-linux-gnu
|
||||
else ifeq ($(shell type mips64-linux-gnu-ld >/dev/null 2>/dev/null; echo $$?), 0)
|
||||
TOOLCHAIN := mips64-linux-gnu
|
||||
else ifeq ($(shell type mips-elf-ld >/dev/null 2>/dev/null; echo $$?), 0)
|
||||
TOOLCHAIN := mips-elf
|
||||
else
|
||||
TOOLCHAIN := mips64-elf
|
||||
TOOLCHAIN := mips-elf
|
||||
endif
|
||||
|
||||
ifeq ($(REGION),ntsc)
|
||||
@ -93,6 +93,7 @@ ASSET_O_FILES := $(patsubst %, %.o, $(ASSET_FILES))
|
||||
|
||||
UCODE_BIN_FILES := \
|
||||
$(B_DIR)/ucode/boot.bin \
|
||||
$(B_DIR)/ucode/filenames.bin \
|
||||
$(B_DIR)/ucode/game.bin \
|
||||
$(B_DIR)/ucode/gvars.bin \
|
||||
$(B_DIR)/ucode/library.bin \
|
||||
@ -276,7 +277,7 @@ test: all
|
||||
@md5sum --quiet -c checksums.md5
|
||||
|
||||
$(B_DIR)/files/%.o: $(B_DIR)/files/%
|
||||
echo -e ".data\n.incbin \"$<\"" > $(B_DIR)/file.s
|
||||
/bin/echo -e ".data\n.incbin \"$<\"" > $(B_DIR)/file.s
|
||||
$(TOOLCHAIN)-as -mabi=32 -mips2 -I src/include -EB -o $@ $(B_DIR)/file.s
|
||||
rm -f file.s
|
||||
|
||||
@ -290,6 +291,15 @@ $(B_DIR)/files/%.bin: $(B_DIR)/files/%.elf
|
||||
$(B_DIR)/files/%Z: $(B_DIR)/files/%.bin
|
||||
tools/rarezip $< > $@
|
||||
|
||||
$(B_DIR)/ucode/filenames.elf: src/filenames.o
|
||||
mkdir -p $(B_DIR)/ucode
|
||||
cp $< build/zero.tmp.o
|
||||
$(TOOLCHAIN)-ld -T ld/zero.ld -o $@
|
||||
rm -f build/zero.tmp.o
|
||||
|
||||
$(B_DIR)/ucode/filenames.bin: $(B_DIR)/ucode/filenames.elf
|
||||
$(TOOLCHAIN)-objcopy $< $@ -O binary
|
||||
|
||||
$(B_DIR)/stage1.elf: $(O_FILES) $(ASSET_O_FILES) ld/stage1.ld
|
||||
cpp -P ld/stage1.ld -o $(B_DIR)/stage1.ld
|
||||
$(TOOLCHAIN)-ld -T $(B_DIR)/stage1.ld --print-map -o $@ > $(B_DIR)/stage1.map
|
||||
|
@ -55,6 +55,7 @@ There is also a stagetable.txt in the repository root which includes multiplayer
|
||||
* make
|
||||
* mips build tools (Debian/Ubuntu: binutils-mips-linux-gnu, Arch: mips64-elf-binutils from AUR)
|
||||
* Python 3
|
||||
* pigz - a zlib compression tool
|
||||
|
||||
## Extracting the base ROM
|
||||
|
||||
|
@ -2529,11 +2529,6 @@ SECTIONS
|
||||
FILE(07dd, Asaucerexp1M, _file_Asaucerexp1M);
|
||||
|
||||
_fileNameList = __rompos;
|
||||
.filenames : {
|
||||
src/filenames.o (.rodata);
|
||||
}
|
||||
__rompos += SIZEOF(.filenames);
|
||||
|
||||
_filesSegmentRomEnd = __rompos;
|
||||
|
||||
/DISCARD/ : {
|
||||
|
@ -1,13 +1,8 @@
|
||||
#include <ultra64.h>
|
||||
|
||||
/**
|
||||
* This file is parsed by tools/build to determine which files to include in the
|
||||
* ROM image and in what order.
|
||||
*
|
||||
* This file is also compiled and included in the ROM image.
|
||||
*/
|
||||
u32 nothing = 0;
|
||||
|
||||
char *filenames[] = {
|
||||
/*0x000*/ "",
|
||||
/*0x001*/ "bgdata/bg_sev.seg",
|
||||
/*0x002*/ "bgdata/bg_silo.seg",
|
||||
/*0x003*/ "bgdata/bg_stat.seg",
|
||||
|
@ -6,6 +6,16 @@ import subprocess
|
||||
|
||||
def main():
|
||||
fd = open('build/ntsc-final/pd.z64', 'wb+')
|
||||
|
||||
# The retail ROM contains truncated duplicates of some segments.
|
||||
# For example, the real boot segment is at 0x1000 - 0x3050, but the tail end
|
||||
# of it is repeated at 0x2ea6c - 0x30a60. The truncated parts are not read
|
||||
# by the ROM; they are likely a side effect of Rare's linker copying things
|
||||
# around in the ROM.
|
||||
write_binary(fd, 0x2ea1c, get_boot())
|
||||
write_binary(fd, 0x30a6c, get_library()[:0x8df0])
|
||||
write_binary(fd, 0x157120, get_unknown())
|
||||
|
||||
write_binary(fd, 0, get_header())
|
||||
write_binary(fd, 0x40, get_rspboot())
|
||||
write_binary(fd, 0x1000, get_boot())
|
||||
@ -13,7 +23,6 @@ def main():
|
||||
write_binary(fd, 0x39850, get_setup())
|
||||
write_binary(fd, 0x4e850, get_rarezip())
|
||||
write_binary(fd, 0x4fc40, get_gamezips())
|
||||
write_binary(fd, 0x157810, get_unknown())
|
||||
write_binary(fd, 0x7f2388, get_fonts())
|
||||
write_binary(fd, 0x80a250, get_sfxctl())
|
||||
write_binary(fd, 0x839dd0, get_sfxtbl())
|
||||
@ -21,6 +30,7 @@ def main():
|
||||
write_binary(fd, 0xd05f90, get_seqtbl())
|
||||
write_binary(fd, 0xe82000, get_midi())
|
||||
write_files(fd)
|
||||
write_binary(fd, 0x1d5ca00, get_filenames())
|
||||
write_binary(fd, 0x1d65f40, get_textures())
|
||||
fd.close()
|
||||
|
||||
@ -64,7 +74,7 @@ def get_gamezips():
|
||||
return getfilecontents('build/ntsc-final/ucode/gamezips.bin')
|
||||
|
||||
def get_unknown():
|
||||
return getfrombaserom(0x157810, 0x69ab78)
|
||||
return getfrombaserom(0x157120, 0x69b268)
|
||||
|
||||
def get_fonts():
|
||||
return getfrombaserom(0x7f2388, 0x17ec8)
|
||||
@ -90,6 +100,9 @@ def write_files(fd):
|
||||
|
||||
write_binary(fd, 0xed83a0, getfromstage1rom(start, end - start))
|
||||
|
||||
def get_filenames():
|
||||
return getfilecontents('build/ntsc-final/ucode/filenames.bin')
|
||||
|
||||
def get_textures():
|
||||
return getfrombaserom(0x01d65f40, 0x29a0c0)
|
||||
|
||||
|
106
tools/mkgamezips
106
tools/mkgamezips
@ -35,12 +35,24 @@ def main():
|
||||
fd.write(pos.to_bytes(4, byteorder='big'))
|
||||
|
||||
# Write data
|
||||
padding_index = 0
|
||||
for index, zip in enumerate(zips):
|
||||
if pos % 2 == 1:
|
||||
fd.write(b'\x00')
|
||||
try:
|
||||
pad_value = padding[padding_index]
|
||||
except KeyError:
|
||||
pad_value = 0
|
||||
fd.write(pad_value.to_bytes(1, 'big'))
|
||||
|
||||
padding_index += 1
|
||||
pos += 1
|
||||
|
||||
fd.write(b'\x00\x00')
|
||||
try:
|
||||
checksum = checksumsmaybe[index]
|
||||
except KeyError:
|
||||
checksum = 0
|
||||
fd.write(checksum.to_bytes(2, 'big'))
|
||||
|
||||
fd.write(zip)
|
||||
pos += len(zip)
|
||||
|
||||
@ -62,8 +74,96 @@ def zip(binary):
|
||||
fd.write(binary)
|
||||
fd.close()
|
||||
|
||||
zipped = subprocess.check_output(['tools/rarezip', 'build/part.bin'])
|
||||
zipped = subprocess.check_output(['tools/rarezip', 'build/part.bin', '--game'])
|
||||
os.remove('build/part.bin')
|
||||
return zipped
|
||||
|
||||
checksumsmaybe = [
|
||||
0x94f1, 0xb0c7, 0x6f10, 0x0d50, 0x2361, 0xe64a, 0x7c32, 0xf8f5,
|
||||
0x8d57, 0x08bf, 0x7ebe, 0xd019, 0x181b, 0xaf2b, 0x1ced, 0xd81c,
|
||||
0xf9cf, 0xdf5c, 0xbb7d, 0x28ab, 0x7107, 0xef7c, 0x671e, 0x6a34,
|
||||
0x01d2, 0x54e3, 0x69a8, 0x523e, 0x5547, 0xb295, 0x4dc9, 0x7e6c,
|
||||
0x3c24, 0x8881, 0x0ebe, 0x7632, 0xaa69, 0x009d, 0x8348, 0xcee0,
|
||||
0xedc5, 0x2554, 0xfa94, 0x75f4, 0x950d, 0xb140, 0x97df, 0x2b99,
|
||||
0xa2a3, 0x847c, 0x557f, 0x7e76, 0x2365, 0x546f, 0x76b8, 0x156f,
|
||||
0x41c3, 0x3903, 0xd96d, 0x8b7c, 0x01ff, 0xf71c, 0xdc78, 0x633a,
|
||||
0xa6b8, 0x7d63, 0xf57b, 0xd3e3, 0xed34, 0xf6e3, 0x4aac, 0x6372,
|
||||
0x12eb, 0x7561, 0xf7e8, 0xc75e, 0xd432, 0x0453, 0x2746, 0x0c38,
|
||||
0x6a9d, 0xf293, 0x53f7, 0xb231, 0x9c55, 0xd107, 0xa106, 0xf5ed,
|
||||
0xc5a9, 0x915f, 0x0673, 0x7f9b, 0x150f, 0x6af0, 0xb018, 0x20b2,
|
||||
0x2504, 0x3d10, 0x11a7, 0xc62e, 0x368a, 0x3b48, 0xf668, 0xddea,
|
||||
0x2ba9, 0xd265, 0xed1a, 0xed92, 0x1439, 0x33d4, 0xbe72, 0x547b,
|
||||
0x13e6, 0xdf3d, 0xc3b3, 0xd04e, 0x7b7a, 0x521f, 0x5f0a, 0xd1af,
|
||||
0xa7fb, 0xcc9a, 0xffe1, 0xa06f, 0xe354, 0xb57c, 0xbd77, 0x686e,
|
||||
0xb747, 0x3e2d, 0xf883, 0x135e, 0x161d, 0x92f7, 0x7422, 0x1e7f,
|
||||
0x3bef, 0x9f6c, 0x4eda, 0xacd8, 0x0574, 0x4277, 0xc814, 0xa2e0,
|
||||
0x155c, 0x5bf7, 0x545e, 0x8a4f, 0x2cd5, 0x7c52, 0x94a7, 0x423e,
|
||||
0x69f4, 0x6402, 0xd3cb, 0x142f, 0x1774, 0x22f9, 0x2bf2, 0x0bc8,
|
||||
0x57f0, 0x80c6, 0x3201, 0x578d, 0xd123, 0x7a2a, 0x7789, 0x6f56,
|
||||
0xef5d, 0xa920, 0xeb3f, 0x0aee, 0xe022, 0x92fc, 0x3b5d, 0x2cb1,
|
||||
0x18ba, 0xc647, 0x830e, 0x6d77, 0xc92b, 0x26a1, 0xe118, 0x3eb0,
|
||||
0xd9af, 0x85ba, 0x0b4f, 0x4af7, 0x5ed7, 0xe071, 0x2f50, 0x6a91,
|
||||
0x2311, 0x4f9d, 0x4455, 0xfb64, 0xbed3, 0x118d, 0xe117, 0x1cc4,
|
||||
0x3e27, 0xb43e, 0xec01, 0xf2b0, 0x37da, 0x2800, 0xc531, 0xd63f,
|
||||
0x7fcd, 0xb361, 0xd265, 0x7700, 0xa774, 0x1f29, 0x58a1, 0x7866,
|
||||
0x0a3c, 0x6ee2, 0x598d, 0x9386, 0xa123, 0x8b36, 0xb54b, 0xcf5e,
|
||||
0x865b, 0x306d, 0x84e4, 0x9a6e, 0x0cc4, 0x5d88, 0xf586, 0x2714,
|
||||
0x5fc0, 0xf0e5, 0x3265, 0x9908, 0x1b5e, 0xcd12, 0xc68c, 0x9850,
|
||||
0xb2dc, 0xcff0, 0x8e41, 0x8fb5, 0xdf13, 0xc46e, 0x08f5, 0x3c18,
|
||||
0x48d7, 0xd98b, 0x8790, 0xf416, 0x7c5c, 0x301f, 0xd40f, 0x2f1f,
|
||||
0xb385, 0x2f7d, 0x646b, 0x5433, 0x2b90, 0x74d4, 0x5ea9, 0xd811,
|
||||
0xc4c8, 0x03ce, 0x056f, 0x84fa, 0x3555, 0x34c8, 0x69e6, 0x8f18,
|
||||
0xa6df, 0xe03e, 0x22c9, 0x3fca, 0x8c43, 0x8fb1, 0x0c68, 0xf91c,
|
||||
0x2858, 0x1123, 0x061b, 0xfcea, 0xfcd5, 0x688e, 0xb033, 0xfe83,
|
||||
0x8d7b, 0xcb4e, 0xdd38, 0xa602, 0xb60d, 0xd447, 0x6f55, 0x40d5,
|
||||
0x83f7, 0x49bc, 0x8923, 0xec93, 0x3242, 0x3db1, 0x0462, 0x5f44,
|
||||
0xab72, 0xcd4c, 0x352b, 0xd602, 0x556a, 0xc7c7, 0x227e, 0x780f,
|
||||
0x46f1, 0xb296, 0xed78, 0x7949, 0x7617, 0x444f, 0x7f4a, 0x612b,
|
||||
0xe63d, 0xb286, 0xe1d2, 0x42e1, 0xd136, 0xddf0, 0x3a29, 0xa623,
|
||||
0x0107, 0xf839, 0x506a, 0xfc70, 0x0410, 0x24fb, 0x35e6, 0x08a1,
|
||||
0x668f, 0xffbe, 0xf4cf, 0xd093, 0xcf0a, 0x6bc4, 0xa173, 0xa12e,
|
||||
0xb552, 0x8da1, 0xa0f5, 0xa909, 0x40d5, 0xcbb3, 0x8e23, 0xe87e,
|
||||
0x3532, 0xcc6b, 0x00ca, 0x98d5, 0x9dbd, 0xa205, 0xb458, 0x2a0d,
|
||||
0xa580, 0xcf78, 0xb691, 0x22e2, 0x0455, 0xcfa7, 0x8505, 0x3387,
|
||||
0xf6e6, 0x98de, 0x736e, 0xa5a8, 0x3cf1, 0x4dd8, 0xf44c, 0xd7ba,
|
||||
0x1c78, 0xb226, 0x6bd6, 0xa3e3, 0xee95, 0x4993, 0x174f, 0x355f,
|
||||
0xb614, 0x6599, 0xb16a, 0x20d4, 0xc414, 0xc0d4, 0x5a48, 0x66b6,
|
||||
0xf118, 0x5ba9, 0x083b, 0x9c9b, 0xa53b, 0x257c, 0xdd0d, 0xbe59,
|
||||
0x8069, 0x06fc, 0xdd59, 0x38e2, 0x0abc, 0xf175, 0x3017, 0xed5d,
|
||||
0x0d10, 0xe322, 0x8a99, 0xe560, 0x943c, 0x4054, 0x28c3, 0xa9ac,
|
||||
0x80d9, 0x6fdb, 0xeb49, 0x3800, 0xe65d, 0xbb45, 0xca90, 0x4af8,
|
||||
0xe1a3, 0x9a50, 0xbc1c, 0xaf92, 0xa169, 0x465e, 0x0000, 0x0000,
|
||||
0x0000, 0x101c, 0x7ca7, 0x0831, 0x0a52, 0x4cb1, 0x7a86, 0xeff6,
|
||||
0xeecb, 0xbf74,
|
||||
]
|
||||
|
||||
padding = [
|
||||
0x00, 0xc2, 0xf9, 0x3a, 0x4d, 0x18, 0x8a, 0x07,
|
||||
0x4c, 0x68, 0x38, 0x17, 0x3c, 0x94, 0x98, 0x25,
|
||||
0x82, 0x6f, 0xf7, 0x2e, 0x41, 0xed, 0xe4, 0x88,
|
||||
0xf5, 0x48, 0x59, 0x5a, 0x7a, 0xb4, 0x3b, 0xf9,
|
||||
0xc7, 0xc7, 0xab, 0xf6, 0xef, 0x23, 0x8b, 0x6a,
|
||||
0x58, 0xb0, 0x27, 0x84, 0x77, 0x88, 0xe1, 0x34,
|
||||
0xf5, 0xf4, 0xa9, 0xb9, 0x30, 0x8a, 0x64, 0x23,
|
||||
0xb5, 0x6c, 0x87, 0xff, 0xd4, 0x84, 0xe4, 0x7c,
|
||||
0x93, 0xa0, 0x5b, 0x41, 0x28, 0xfa, 0x65, 0x3e,
|
||||
0xad, 0x51, 0x35, 0xf9, 0xec, 0x6a, 0xe9, 0xaf,
|
||||
0xe0, 0x7f, 0xe5, 0x8e, 0x0e, 0x6b, 0x42, 0x97,
|
||||
0xee, 0xad, 0x5d, 0xba, 0x91, 0x7c, 0xd6, 0x91,
|
||||
0xb3, 0xbd, 0x5f, 0x3d, 0x48, 0xd1, 0x37, 0xba,
|
||||
0xfc, 0x83, 0x51, 0x2b, 0xcb, 0x2f, 0x6b, 0xbf,
|
||||
0xb0, 0xe5, 0x9c, 0xac, 0x1d, 0x63, 0xcb, 0xa5,
|
||||
0x5e, 0x66, 0x24, 0x2d, 0xe3, 0x86, 0x3e, 0x0c,
|
||||
0xcf, 0x1a, 0x57, 0xc9, 0x4b, 0x29, 0x70, 0x31,
|
||||
0xbb, 0x55, 0xc4, 0x42, 0x62, 0x5e, 0x9a, 0xa0,
|
||||
0xff, 0x41, 0xf5, 0x62, 0x9f, 0xc9, 0x61, 0xee,
|
||||
0xbe, 0x7b, 0x0e, 0xf2, 0xd7, 0xf1, 0x90, 0x69,
|
||||
0xfa, 0xff, 0xf7, 0xb1, 0x3a, 0x27, 0xac, 0xc2,
|
||||
0x57, 0x7e, 0xcc, 0x92, 0xdd, 0x2d, 0x63, 0xa0,
|
||||
0x53, 0x74, 0x35, 0xbb, 0x24, 0xde, 0x6d, 0xbb,
|
||||
0x2c, 0xe5, 0xff, 0xeb, 0x37, 0xde, 0xd0, 0x6e,
|
||||
0x96, 0xfa, 0xbe, 0x79, 0xe3, 0x1e, 0x7f, 0xff,
|
||||
0x67, 0x86, 0x86, 0x86, 0x15, 0x6e,
|
||||
]
|
||||
|
||||
main()
|
||||
|
@ -4,4 +4,10 @@ size=$(stat --format="%s" $1)
|
||||
|
||||
printf "0: 1173 %.6x" $size | xxd -r -g0
|
||||
|
||||
cat $1 | tools/gzip --no-name --best | head --bytes=-8 | tail --bytes=+11
|
||||
if [[ "$2" == '--game' ]]; then
|
||||
# Use pigz, which uses the zlib library
|
||||
pigz -c --no-name --best $1 | head --bytes=-8 | tail --bytes=+11
|
||||
else
|
||||
# Use gzip, which uses their own deflate implementation
|
||||
tools/gzip -c --no-name --best $1 | head --bytes=-8 | tail --bytes=+11
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user