Introduce preamble segment and disassemble preamble
This commit is contained in:
parent
d6a0d4745a
commit
d425d4f11c
2
Makefile
2
Makefile
|
@ -175,7 +175,7 @@ CFLAGS = $(C_DEFINES) \
|
|||
ASFLAGS = -march=vr4300 -mabi=32 -Isrc/include $(AS_DEFINES)
|
||||
|
||||
C_FILES := $(shell find src/lib src/game src/inflate -name '*.c')
|
||||
S_FILES := $(shell find src/lib src/game -name '*.s')
|
||||
S_FILES := $(shell find src/lib src/game src/preamble -name '*.s')
|
||||
|
||||
# Create names such as $(B_DIR)/assets/files/PfooZ.
|
||||
# These names (with .o added) will be dependenices for ld.
|
||||
|
|
|
@ -2018,7 +2018,7 @@ d41d8cd98f00b204e9800998ecf8427e build/jpn-final/assets/files/ob/ob_mid.seg
|
|||
bd6e5fc360d5e0c35ea3605e2514f205 build/jpn-final/segments/game.bin
|
||||
22d5e92bffcc67b222cf3697e96106f6 build/jpn-final/segments/data.bin
|
||||
843285fdc0e80a77576eeb73940d2fd3 build/jpn-final/segments/inflate.bin
|
||||
dd3b5fe7696544bb41e97cfae67fd431 build/jpn-final/segments/lib.bin
|
||||
8666f5d44c34096e3de2b45cb3fec122 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
|
||||
|
@ -2027,4 +2027,5 @@ c47d9377956666bc0e77d6cba3dc68fb build/jpn-final/segments/mpconfigs.bin
|
|||
b60f7439adaf8b1e150ab54b590da411 build/jpn-final/segments/mpstringsJ.bin
|
||||
529b54a03375af2ff74eb3367cbac294 build/jpn-final/segments/mpstringsP.bin
|
||||
9e9ad9fdc9b6a3c249a370760fa23b26 build/jpn-final/segments/mpstringsS.bin
|
||||
bb5f33663dfff68959ec9606dd405f45 build/jpn-final/segments/preamble.bin
|
||||
09fdd15fcbdcdecb096d3818c9f83026 build/jpn-final/segments/textureconfig.bin
|
||||
|
|
|
@ -2016,7 +2016,7 @@ 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
|
||||
0ee07d5d8e890e264e775e4034e3b900 build/ntsc-1.0/segments/lib.bin
|
||||
fcc20ca686e49e64d9146a441fc43203 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
|
||||
|
@ -2025,4 +2025,5 @@ e4f45399a4f97e3fd6733f0f6919d28d build/ntsc-1.0/segments/mpstringsI.bin
|
|||
302f7aa0464c781187551fcd3870aec2 build/ntsc-1.0/segments/mpstringsJ.bin
|
||||
e4f45399a4f97e3fd6733f0f6919d28d build/ntsc-1.0/segments/mpstringsP.bin
|
||||
e4f45399a4f97e3fd6733f0f6919d28d build/ntsc-1.0/segments/mpstringsS.bin
|
||||
4eb4b73612420d7133ece3c2e4d1bd2f build/ntsc-1.0/segments/preamble.bin
|
||||
09fdd15fcbdcdecb096d3818c9f83026 build/ntsc-1.0/segments/textureconfig.bin
|
||||
|
|
|
@ -2015,7 +2015,7 @@ a12b5437510403bb09b3cceb45dd2a10 build/ntsc-beta/segments/firingrange.bin
|
|||
daae19f7ce11d3f3e1f98d543ad856f5 build/ntsc-beta/segments/game.bin
|
||||
cab47b8c30b1be608c1c5c1db08342de build/ntsc-beta/segments/data.bin
|
||||
843285fdc0e80a77576eeb73940d2fd3 build/ntsc-beta/segments/inflate.bin
|
||||
900199658b5cfb5a3c16844abc9da56e build/ntsc-beta/segments/lib.bin
|
||||
2b787e7deb0f2df04dcdf02ac785d93e 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
|
||||
|
@ -2024,4 +2024,5 @@ e4f45399a4f97e3fd6733f0f6919d28d build/ntsc-beta/segments/mpstringsI.bin
|
|||
302f7aa0464c781187551fcd3870aec2 build/ntsc-beta/segments/mpstringsJ.bin
|
||||
e4f45399a4f97e3fd6733f0f6919d28d build/ntsc-beta/segments/mpstringsP.bin
|
||||
e4f45399a4f97e3fd6733f0f6919d28d build/ntsc-beta/segments/mpstringsS.bin
|
||||
c24166092dd15d4fcc510cfb3d615bce build/ntsc-beta/segments/preamble.bin
|
||||
09fdd15fcbdcdecb096d3818c9f83026 build/ntsc-beta/segments/textureconfig.bin
|
||||
|
|
|
@ -2016,7 +2016,7 @@ 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
|
||||
5ab66459c09843f5953718643c998625 build/ntsc-final/segments/lib.bin
|
||||
9888fecfc1408fd49aeecc94743c1a20 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
|
||||
|
@ -2025,4 +2025,5 @@ e4f45399a4f97e3fd6733f0f6919d28d build/ntsc-final/segments/mpstringsF.bin
|
|||
e4f45399a4f97e3fd6733f0f6919d28d build/ntsc-final/segments/mpstringsG.bin
|
||||
e4f45399a4f97e3fd6733f0f6919d28d build/ntsc-final/segments/mpstringsI.bin
|
||||
e4f45399a4f97e3fd6733f0f6919d28d build/ntsc-final/segments/mpstringsS.bin
|
||||
4eb4b73612420d7133ece3c2e4d1bd2f build/ntsc-final/segments/preamble.bin
|
||||
09fdd15fcbdcdecb096d3818c9f83026 build/ntsc-final/segments/textureconfig.bin
|
||||
|
|
|
@ -2016,7 +2016,7 @@ ad2de210a3455ba5ec541f0c78d91444 build/pal-beta/pd.z64
|
|||
ad5835b91b7e252ef8f4a421a44eb12b build/pal-beta/segments/game.bin
|
||||
bca5001a5dd0ef9aab24ba085f27eb40 build/pal-beta/segments/data.bin
|
||||
843285fdc0e80a77576eeb73940d2fd3 build/pal-beta/segments/inflate.bin
|
||||
317967a2f69b8e33ce588b0223ea3859 build/pal-beta/segments/lib.bin
|
||||
7a689272c17a207c662720bedaf548f5 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
|
||||
|
@ -2025,4 +2025,5 @@ fed3dc54a3564f477fb7d548ac365514 build/pal-beta/segments/mpstringsI.bin
|
|||
302f7aa0464c781187551fcd3870aec2 build/pal-beta/segments/mpstringsJ.bin
|
||||
529b54a03375af2ff74eb3367cbac294 build/pal-beta/segments/mpstringsP.bin
|
||||
d9501d67ead982fdd5cb5ffaf3091201 build/pal-beta/segments/mpstringsS.bin
|
||||
2b87fded07e5181b7db8556dc6c541e7 build/pal-beta/segments/preamble.bin
|
||||
09fdd15fcbdcdecb096d3818c9f83026 build/pal-beta/segments/textureconfig.bin
|
||||
|
|
|
@ -2016,7 +2016,7 @@ d9b5cd305d228424891ce38e71bc9213 build/pal-final/pd.z64
|
|||
4e506821044251aecc10ec332389c576 build/pal-final/segments/game.bin
|
||||
1c49c171e829a5407f0ae5fd28a123cd build/pal-final/segments/data.bin
|
||||
843285fdc0e80a77576eeb73940d2fd3 build/pal-final/segments/inflate.bin
|
||||
ba4edc92cda812aaddff2810be77dbf7 build/pal-final/segments/lib.bin
|
||||
6d1e2a1a824ff7caa1d4863f595dce12 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
|
||||
|
@ -2025,4 +2025,5 @@ ba4edc92cda812aaddff2810be77dbf7 build/pal-final/segments/lib.bin
|
|||
302f7aa0464c781187551fcd3870aec2 build/pal-final/segments/mpstringsJ.bin
|
||||
529b54a03375af2ff74eb3367cbac294 build/pal-final/segments/mpstringsP.bin
|
||||
9e9ad9fdc9b6a3c249a370760fa23b26 build/pal-final/segments/mpstringsS.bin
|
||||
96cf3bb3bae53a580eee1121744f745d build/pal-final/segments/preamble.bin
|
||||
09fdd15fcbdcdecb096d3818c9f83026 build/pal-final/segments/textureconfig.bin
|
||||
|
|
38
ld/pd.ld
38
ld/pd.ld
|
@ -25,7 +25,8 @@
|
|||
__rompos += SIZEOF(.name); \
|
||||
__rampos = ADDR(.name) + SIZEOF(.name); \
|
||||
_##name##SegmentEnd = ADDR(.name) + SIZEOF(.name); \
|
||||
_##name##SegmentRomEnd = __rompos;
|
||||
_##name##SegmentRomEnd = __rompos; \
|
||||
_##name##SegmentLen = _##name##SegmentEnd - _##name##SegmentStart;
|
||||
|
||||
#define MPSTRINGS(lang) \
|
||||
BEGIN_SEG(mpstrings##lang) \
|
||||
|
@ -75,11 +76,11 @@
|
|||
*/
|
||||
|
||||
#if VERSION >= VERSION_PAL_FINAL
|
||||
#define ROMALLOCATION_LIB 0x038850
|
||||
#define ROMALLOCATION_LIB 0x038800
|
||||
#define ROMALLOCATION_DATA 0x015000
|
||||
#define ROMALLOCATION_GAME 0x13d180
|
||||
#else
|
||||
#define ROMALLOCATION_LIB 0x038850
|
||||
#define ROMALLOCATION_LIB 0x038800
|
||||
#define ROMALLOCATION_DATA 0x015000
|
||||
#define ROMALLOCATION_GAME 0x151980
|
||||
#endif
|
||||
|
@ -187,6 +188,29 @@ SECTIONS
|
|||
}
|
||||
END_SEG(bootloader)
|
||||
|
||||
/***************************************************************************
|
||||
* preamble
|
||||
* -------------------------------------------------------------------------
|
||||
* ROM range: 0x00001000 - 0x00001050
|
||||
* RAM range: 0x70001000 - 0x70001050
|
||||
* -------------------------------------------------------------------------
|
||||
* This segment contains the entry function.
|
||||
*/
|
||||
|
||||
BEGIN_SEG(preamble)
|
||||
{
|
||||
build/ROMID/preamble/preamble.o (.text);
|
||||
. = ALIGN(0x30);
|
||||
}
|
||||
END_SEG(preamble)
|
||||
|
||||
/**
|
||||
/* boot()'s address is 0x70001050, but preamble calls it by 0x80001050 due
|
||||
* to it not being TLB mapped yet. So we set up this variable to allow this
|
||||
* to happen.
|
||||
*/
|
||||
bootFromPreamble = boot + 0x10000000;
|
||||
|
||||
/***************************************************************************
|
||||
* lib
|
||||
* -------------------------------------------------------------------------
|
||||
|
@ -195,10 +219,12 @@ SECTIONS
|
|||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
__rompos = 0x00001050;
|
||||
|
||||
PLACEHOLDER_SEGMENT(libzip)
|
||||
|
||||
__rompos = 0x02000000;
|
||||
__rampos = 0x70001000;
|
||||
__rampos = 0x70001050;
|
||||
|
||||
BEGIN_SEG(lib) SUBALIGN(16)
|
||||
{
|
||||
|
@ -207,8 +233,6 @@ SECTIONS
|
|||
}
|
||||
END_SEG(lib)
|
||||
|
||||
_libSegmentStart = 0x70001050;
|
||||
|
||||
/***************************************************************************
|
||||
* data
|
||||
* -------------------------------------------------------------------------
|
||||
|
@ -224,7 +248,7 @@ SECTIONS
|
|||
PLACEHOLDER_SEGMENT(datazip)
|
||||
|
||||
__rompos = __savedrompos;
|
||||
__rampos = 0x80001000 + SIZEOF(.lib);
|
||||
__rampos = 0x80001050 + SIZEOF(.lib);
|
||||
|
||||
BEGIN_SEG(data)
|
||||
{
|
||||
|
|
|
@ -39,62 +39,6 @@ u32 var8008d264;
|
|||
u32 var8008d268;
|
||||
u32 var8008d26c;
|
||||
|
||||
/**
|
||||
* This function is generated automatically by makerom. It clears the BSS
|
||||
* segment, sets the stack pointer to 0x80000f10 and then calls boot.
|
||||
*/
|
||||
#if VERSION >= VERSION_PAL_FINAL
|
||||
GLOBAL_ASM(
|
||||
glabel preamble
|
||||
/* 1000: 3c088009 */ lui $t0,%hi(_bssSegmentStart)
|
||||
/* 1004: 3c090002 */ lui $t1,0x2
|
||||
/* 1008: 2508ae20 */ addiu $t0,$t0,%lo(_bssSegmentStart)
|
||||
/* 100c: 352923a0 */ ori $t1,$t1,0x23f0
|
||||
.L00001010:
|
||||
/* 1010: 2129fff8 */ addi $t1,$t1,-8
|
||||
/* 1014: ad000000 */ sw $zero,0x0($t0)
|
||||
/* 1018: ad000004 */ sw $zero,0x4($t0)
|
||||
/* 101c: 1520fffc */ bnez $t1,.L00001010
|
||||
/* 1020: 21080008 */ addi $t0,$t0,0x8
|
||||
/* 1024: 3c0a8000 */ lui $t2,0x8000
|
||||
/* 1028: 3c1d8000 */ lui $sp,0x8000
|
||||
/* 102c: 254a1050 */ addiu $t2,$t2,0x1050
|
||||
/* 1030: 01400008 */ jr $t2
|
||||
/* 1034: 27bd0f10 */ addiu $sp,$sp,0xf10
|
||||
/* 1038: 00000000 */ nop
|
||||
/* 103c: 00000000 */ nop
|
||||
/* 1040: 00000000 */ nop
|
||||
/* 1044: 00000000 */ nop
|
||||
/* 1048: 00000000 */ nop
|
||||
/* 104c: 00000000 */ nop
|
||||
);
|
||||
#else
|
||||
GLOBAL_ASM(
|
||||
glabel preamble
|
||||
/* 1000: 3c088009 */ lui $t0,%hi(_bssSegmentStart)
|
||||
/* 1004: 3c090002 */ lui $t1,0x2
|
||||
/* 1008: 2508ae20 */ addiu $t0,$t0,%lo(_bssSegmentStart)
|
||||
/* 100c: 352923a0 */ ori $t1,$t1,0x23a0
|
||||
.L00001010:
|
||||
/* 1010: 2129fff8 */ addi $t1,$t1,-8
|
||||
/* 1014: ad000000 */ sw $zero,0x0($t0)
|
||||
/* 1018: ad000004 */ sw $zero,0x4($t0)
|
||||
/* 101c: 1520fffc */ bnez $t1,.L00001010
|
||||
/* 1020: 21080008 */ addi $t0,$t0,0x8
|
||||
/* 1024: 3c0a8000 */ lui $t2,0x8000
|
||||
/* 1028: 3c1d8000 */ lui $sp,0x8000
|
||||
/* 102c: 254a1050 */ addiu $t2,$t2,0x1050
|
||||
/* 1030: 01400008 */ jr $t2
|
||||
/* 1034: 27bd0f10 */ addiu $sp,$sp,0xf10
|
||||
/* 1038: 00000000 */ nop
|
||||
/* 103c: 00000000 */ nop
|
||||
/* 1040: 00000000 */ nop
|
||||
/* 1044: 00000000 */ nop
|
||||
/* 1048: 00000000 */ nop
|
||||
/* 104c: 00000000 */ nop
|
||||
);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Sets up TLB index 0 (0x70000000), then calls init.
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
#include "macros.inc"
|
||||
.set noat
|
||||
.set noreorder
|
||||
|
||||
.text
|
||||
|
||||
/**
|
||||
* This function is generated automatically by makerom. It clears the BSS
|
||||
* segment, sets the stack pointer to 0x80000f10 and then calls boot.
|
||||
*/
|
||||
glabel preamble
|
||||
lui $t0, %hi(_bssSegmentStart)
|
||||
lui $t1, %hi(_bssSegmentLen)
|
||||
addiu $t0, $t0, %lo(_bssSegmentStart)
|
||||
ori $t1, $t1, %lo(_bssSegmentLen)
|
||||
.L00001010:
|
||||
addi $t1, $t1, -8
|
||||
sw $zero, 0($t0)
|
||||
sw $zero, 4($t0)
|
||||
bnez $t1, .L00001010
|
||||
addi $t0, $t0, 8
|
||||
lui $t2, %hi(bootFromPreamble)
|
||||
lui $sp, 0x8000
|
||||
addiu $t2, $t2, %lo(bootFromPreamble)
|
||||
jr $t2
|
||||
addiu $sp, $sp, 0xf10
|
|
@ -32,6 +32,7 @@ class Extractor:
|
|||
self.extract_lib()
|
||||
self.extract_mpconfigs()
|
||||
self.extract_mpstrings()
|
||||
self.extract_preamble()
|
||||
self.extract_rsp()
|
||||
self.extract_textureconfig()
|
||||
self.extract_textures()
|
||||
|
@ -197,9 +198,9 @@ class Extractor:
|
|||
end = self.val('animations')
|
||||
self.write_extracted('garbage2.bin', self.rom[start:end])
|
||||
|
||||
# In all versions, lib starts at 0x1000 and is compressed from 0x3050 onwards
|
||||
# In all versions, lib starts at 0x1050 and is compressed from 0x3050 onwards
|
||||
def extract_lib(self):
|
||||
part1 = self.rom[0x1000:0x3050]
|
||||
part1 = self.rom[0x1050:0x3050]
|
||||
part2 = self.decompress(self.rom[0x3050:])
|
||||
self.write_extracted('lib.bin', part1 + part2)
|
||||
|
||||
|
@ -244,6 +245,9 @@ class Extractor:
|
|||
def extract_bootloader(self):
|
||||
self.write_extracted('bootloader.bin', self.rom[0x40:0x1000])
|
||||
|
||||
def extract_preamble(self):
|
||||
self.write_extracted('preamble.bin', self.rom[0x1000:0x1050])
|
||||
|
||||
def extract_rsp_segment(self, name, pos, length):
|
||||
if pos < 0:
|
||||
pos = len(self.data) + pos
|
||||
|
|
|
@ -68,10 +68,10 @@ def get_segment(fd, locations, segname):
|
|||
fd.seek(start)
|
||||
return fd.read(end - start)
|
||||
|
||||
# lib is compressed from offset 0x2050 onwards
|
||||
# lib is compressed from offset 0x2000 onwards
|
||||
def pack_lib(fd, locations):
|
||||
lib = get_segment(fd, locations, 'lib')
|
||||
zipped = lib[0:0x2050] + zip(lib[0x2050:])
|
||||
zipped = lib[0:0x2000] + zip(lib[0x2000:])
|
||||
attempt(fd, locations, 'lib', zipped, 'ROMALLOCATION_LIB')
|
||||
|
||||
def pack_data(fd, locations):
|
||||
|
|
Loading…
Reference in New Issue