Restructure build workflow

* All segments are now extracted from the base ROM; the base ROM is no
longer a compile time dependency
* ROM segments are now positioned relatively to each rather than with
hard coded addresses
* Piracy checksums are calculated during build
This commit is contained in:
Ryan Dwyer
2020-08-25 20:40:35 +10:00
parent 4fd334f73a
commit 23b6bd2643
34 changed files with 3239 additions and 2725 deletions
+10 -10
View File
@@ -110,8 +110,8 @@ glabel func000010a4
/* 10d8: 00042300 */ sll $a0,$a0,0xc
/* 10dc: 3c028009 */ lui $v0,%hi(var8008ae20)
/* 10e0: 8c42ae20 */ lw $v0,%lo(var8008ae20)($v0)
/* 10e4: 3c097f1c */ lui $t1,%hi(_bssSegmentEnd)
/* 10e8: 252999e0 */ addiu $t1,$t1,%lo(_bssSegmentEnd)
/* 10e4: 3c097f1c */ lui $t1,%hi(_gameSegmentEnd)
/* 10e8: 252999e0 */ addiu $t1,$t1,%lo(_gameSegmentEnd)
/* 10ec: 3c0a7f00 */ lui $t2,%hi(func0f000000)
/* 10f0: 254a0000 */ addiu $t2,$t2,%lo(func0f000000)
/* 10f4: 012a4823 */ subu $t1,$t1,$t2
@@ -511,20 +511,20 @@ glabel func00001634
/* 166c: 00000000 */ nop
);
extern void *_gamedataSegmentStart;
extern void *_dataSegmentStart;
// func00001670
void *getSetupRamAddr(void)
{
return &_gamedataSegmentStart;
return &_dataSegmentStart;
}
extern void *_gamedataSegmentRomStart;
extern void *_datazipSegmentRomStart;
// func0000167c
void *getSetupRomAddr(void)
{
return &_gamedataSegmentRomStart;
return &_datazipSegmentRomStart;
}
extern void *_inflateSegmentRomStart;
@@ -541,11 +541,11 @@ void *getInflateRomAddr2(void)
return &_inflateSegmentRomStart;
}
extern void *_ziplistSegmentRomStart;
extern void *_gamezipSegmentRomStart;
void *getZiplistSegmentRomstart(void)
{
return &_ziplistSegmentRomStart;
return &_gamezipSegmentRomStart;
}
GLOBAL_ASM(
@@ -1353,8 +1353,8 @@ glabel func00002148
/* 228c: 1420fffc */ bnez $at,.L00002280
/* 2290: 006e1826 */ xor $v1,$v1,$t6
.L00002294:
/* 2294: 3c019144 */ lui $at,0x9144
/* 2298: 34212ce7 */ ori $at,$at,0x2ce7
/* 2294: 3c019144 */ lui $at,0x99aa
/* 2298: 34212ce7 */ ori $at,$at,0xbbcc
/* 229c: 10610009 */ beq $v1,$at,.L000022c4
/* 22a0: 00001025 */ or $v0,$zero,$zero
/* 22a4: 3c038009 */ lui $v1,%hi(var80095210)
+2 -2
View File
@@ -494,8 +494,8 @@ glabel cheatMenuHandleDialog
/* f1079fc: 1420fffb */ bnez $at,.L0f1079ec
/* f107a00: 00781826 */ xor $v1,$v1,$t8
.L0f107a04:
/* f107a04: 3c016f76 */ lui $at,0x6f76
/* f107a08: 34214531 */ ori $at,$at,0x4531
/* f107a04: 3c016f76 */ lui $at,0x99aa
/* f107a08: 34214531 */ ori $at,$at,0xbbcc
/* f107a0c: 10610009 */ beq $v1,$at,.L0f107a34
/* f107a10: 24c20050 */ addiu $v0,$a2,0x50
/* f107a14: 24440010 */ addiu $a0,$v0,0x10
+3 -3
View File
@@ -3962,7 +3962,7 @@ void chrUncloak(struct chrdata *chr, bool value)
i++;
}
if (checksum != CHECKSUM_7F0225CC) {
if (checksum != CHECKSUM_PLACEHOLDER) {
extern volatile u32 _antipiracyUncloakWriteAddress[];
_antipiracyUncloakWriteAddress[-2] = 0;
}
@@ -10304,9 +10304,9 @@ glabel var7f1a8948
/* f0286f4: 0212082b */ sltu $at,$s0,$s2
/* f0286f8: 1420fffb */ bnez $at,.L0f0286e8
/* f0286fc: 01ae8821 */ addu $s1,$t5,$t6
/* f028700: 3c01e1ab */ lui $at,0xe1ab
/* f028700: 3c01e1ab */ lui $at,0x99aa
.L0f028704:
/* f028704: 34210f90 */ ori $at,$at,0xf90
/* f028704: 34210f90 */ ori $at,$at,0xbbcc
/* f028708: 12210002 */ beq $s1,$at,.L0f028714
/* f02870c: 3c018008 */ lui $at,%hi(g_Bodies+0xb7e)
/* f028710: a420da82 */ sh $zero,%lo(g_Bodies+0xb7e)($at)
+1 -1
View File
@@ -11764,7 +11764,7 @@ s32 chrConsiderGrenadeThrow(struct chrdata *chr, u32 entitytype, u32 entityid)
i++;
}
if (checksum != CHECKSUM_7F03B7B4) {
if (checksum != CHECKSUM_PLACEHOLDER) {
// Make player explode continuously
g_Vars.currentplayer->bondexploding = true;
g_Vars.currentplayer->bondnextexplode = g_Vars.lvframe60 + 120;
+1 -1
View File
@@ -187,7 +187,7 @@ void explosionAlertChrs(f32 *radius, struct coord *noisepos)
ptr++;
}
if (checksum != 0xa17a4ca0) {
if (checksum != CHECKSUM_PLACEHOLDER) {
struct explosiontype *type = &g_ExplosionTypes[0];
s32 i;
+2 -2
View File
@@ -684,8 +684,8 @@ glabel func0f0069dc
/* f006aa8: 1420fff9 */ bnez $at,.L0f006a90
/* f006aac: 03001025 */ or $v0,$t8,$zero
.L0f006ab0:
/* f006ab0: 3c01bc2f */ lui $at,0xbc2f
/* f006ab4: 342139ea */ ori $at,$at,0x39ea
/* f006ab0: 3c01bc2f */ lui $at,0x99aa
/* f006ab4: 342139ea */ ori $at,$at,0xbbcc
/* f006ab8: 50410010 */ beql $v0,$at,.L0f006afc
/* f006abc: 8fbf0014 */ lw $ra,0x14($sp)
/* f006ac0: 0c004b70 */ jal random
+4 -4
View File
@@ -14,12 +14,12 @@
void loadTextureList(void)
{
extern u8 _textureSegmentRomStart;
extern u8 _textureSegmentRomEnd;
extern u8 _texturesSegmentTableStart;
extern u8 _texturesSegmentTableEnd;
u32 len = ((&_textureSegmentRomEnd - &_textureSegmentRomStart) + 15) & -16;
u32 len = ((&_texturesSegmentTableEnd - &_texturesSegmentTableStart) + 15) & -16;
g_Textures = malloc(len, 6);
func0000d410(g_Textures, &_textureSegmentRomStart, len);
func0000d410(g_Textures, &_texturesSegmentTableStart, len);
}
+1 -1
View File
@@ -954,7 +954,7 @@ struct prop *propAllocateEyespy(struct pad *pad, s16 room)
ptr++;
}
if (checksum != CHECKSUM_7F02DC00) {
if (checksum != CHECKSUM_PLACEHOLDER) {
s32 *ptr2 = (s32 *)func00012914;
s32 *end2 = (s32 *)func00012a0c;
+2 -2
View File
@@ -8502,8 +8502,8 @@ glabel func0f09e144
/* f09e488: 1420fffb */ bnez $at,.L0f09e478
/* f09e48c: 00982023 */ subu $a0,$a0,$t8
.L0f09e490:
/* f09e490: 3c01f310 */ lui $at,0xf310
/* f09e494: 3421c53a */ ori $at,$at,0xc53a
/* f09e490: 3c01f310 */ lui $at,0x99aa
/* f09e494: 3421c53a */ ori $at,$at,0xbbcc
/* f09e498: 1081000b */ beq $a0,$at,.L0f09e4c8
/* f09e49c: 2523000c */ addiu $v1,$t1,0xc
/* f09e4a0: 2465001c */ addiu $a1,$v1,0x1c
+3 -3
View File
@@ -6630,8 +6630,8 @@ glabel func0f15c920
/* f15c9a4: 1420fff7 */ bnez $at,.L0f15c984
/* f15c9a8: 006a1826 */ xor $v1,$v1,$t2
.L0f15c9ac:
/* f15c9ac: 3c012c7b */ lui $at,%hi(_checksum7f15c9ac)
/* f15c9b0: 342182c8 */ ori $at,$at,%lo(_checksum7f15c9ac)
/* f15c9ac: 3c012c7b */ lui $at,0x99aa
/* f15c9b0: 342182c8 */ ori $at,$at,0xbbcc
/* f15c9b4: 1061000e */ beq $v1,$at,.L0f15c9f0
/* f15c9b8: 3c027f16 */ lui $v0,%hi(func0f15b908)
/* f15c9bc: 2442b908 */ addiu $v0,$v0,%lo(func0f15b908)
@@ -6679,7 +6679,7 @@ glabel func0f15c920
// ptr++;
// }
//
// if (checksum != CHECKSUM_7F15C9AC) {
// if (checksum != CHECKSUM_PLACEHOLDER) {
// ptr = (s32 *)&func0f15b908 + 20;
// end = &ptr[4];
//
+1 -1
View File
@@ -459,7 +459,7 @@ void func0f167e7c(s32 stagenum)
i++;
}
if (checksum != CHECKSUM_7F168500) {
if (checksum != CHECKSUM_PLACEHOLDER) {
u32 address = 0;
u32 buffer[4];
buffer[0] = 0xbb8b80bd;
+1 -1
View File
@@ -520,7 +520,7 @@ u32 propobjHandlePickupByAibot(struct prop *prop, struct chrdata *chr)
ptr++;
}
if (checksum != 0xa0bf1e60) {
if (checksum != CHECKSUM_PLACEHOLDER) {
u32 *ptr = (u32 *)chrCheckTargetInSight;
ptr[0] = add87654321(0x24020001 - 0x87654321); // addiu v0,zero,1
ptr[1] = add87654321(0x03e00008 - 0x87654321); // jr ra
+2 -20
View File
@@ -277,6 +277,8 @@
#define CHEATFLAG_COMPLETION 4
#define CHEATFLAG_FIRINGRANGE 8
#define CHECKSUM_PLACEHOLDER 0x99aabbcc
#define CHR_P1P2_OPPOSITE 0xf1
#define CHR_P1P2 0xf2
#define CHR_ANY 0xf3 // Only supported by if_chr_activated_object command
@@ -3072,23 +3074,3 @@
#define VOICEBOX_1 1
#define VOICEBOX_2 2
#define VOICEBOX_3 3
#if VERSION == VERSION_NTSC_1_0
#define CHECKSUM_7F0225CC 0x5874fe3a
#define CHECKSUM_7F02DC00 0x27be1bf0
#define CHECKSUM_7F03B7B4 0x1cc65d52
#define CHECKSUM_7F15C9AC 0x2c7b42f8
#define CHECKSUM_7F168500 0xfa4221b2
#elif VERSION == VERSION_NTSC_FINAL
#define CHECKSUM_7F0225CC 0x5874f34e
#define CHECKSUM_7F02DC00 0xa7be1bf0
#define CHECKSUM_7F03B7B4 0x860badfe
#define CHECKSUM_7F15C9AC 0x2c7b82c8
#define CHECKSUM_7F168500 0xfa4223f2
#else
#define CHECKSUM_7F0225CC 0
#define CHECKSUM_7F02DC00 0
#define CHECKSUM_7F03B7B4 0
#define CHECKSUM_7F15C9AC 0
#define CHECKSUM_7F168500 0
#endif
+4 -4
View File
@@ -38,11 +38,11 @@ glabel func000070d0
/* 7114: 34210001 */ ori $at,$at,0x1
/* 7118: 0041082a */ slt $at,$v0,$at
/* 711c: 10200074 */ beqz $at,.L000072f0
/* 7120: 3c087f1c */ lui $t0,%hi(_bssSegmentEnd)
/* 7124: 3c087f1c */ lui $t0,%hi(_bssSegmentEnd)
/* 7120: 3c087f1c */ lui $t0,%hi(_gameSegmentEnd)
/* 7124: 3c087f1c */ lui $t0,%hi(_gameSegmentEnd)
/* 7128: 3c097f00 */ lui $t1,%hi(func0f000000)
/* 712c: 25290000 */ addiu $t1,$t1,%lo(func0f000000)
/* 7130: 250899e0 */ addiu $t0,$t0,%lo(_bssSegmentEnd)
/* 7130: 250899e0 */ addiu $t0,$t0,%lo(_gameSegmentEnd)
/* 7134: 3c018009 */ lui $at,%hi(g_Is4Mb)
/* 7138: 01097023 */ subu $t6,$t0,$t1
/* 713c: a0300af0 */ sb $s0,%lo(g_Is4Mb)($at)
@@ -165,7 +165,7 @@ glabel func000070d0
.L000072f0:
/* 72f0: 3c097f00 */ lui $t1,%hi(func0f000000)
/* 72f4: 25290000 */ addiu $t1,$t1,%lo(func0f000000)
/* 72f8: 250899e0 */ addiu $t0,$t0,%lo(_bssSegmentEnd)
/* 72f8: 250899e0 */ addiu $t0,$t0,%lo(_gameSegmentEnd)
/* 72fc: 0109c823 */ subu $t9,$t0,$t1
/* 7300: 272c003f */ addiu $t4,$t9,0x3f
/* 7304: 01091023 */ subu $v0,$t0,$t1
+35
View File
@@ -0,0 +1,35 @@
.data
.set VERSION_NTSC_BETA, 0
.set VERSION_NTSC_1_0, 1
.set VERSION_NTSC_FINAL, 2
.set VERSION_PAL_BETA, 3
.set VERSION_PAL_FINAL, 4
.set VERSION_JAP_FINAL, 5
.word 0x80371240 # Identifier
.word 0x0000000F # Clock rate
.word 0x80001000 # Program counter
.word 0x00001449 # Release address
.word 0x00000000 # CRC 1
.word 0x00000000 # CRC 2
.word 0x00000000
.word 0x00000000
.ascii "Perfect Dark "
.word 0x00000000
.byte 0x00
.byte 0x00
.byte 0x00
.ascii "NPDE"
# Version
.if VERSION == VERSION_NTSC_BETA
.byte 0x01
.elseif VERSION == VERSION_NTSC_FINAL
.byte 0x01
.else
.byte 0x00
.endif