Rename init.c to boot.c
This commit is contained in:
parent
f616ee8307
commit
c5d2900c56
|
|
@ -8,7 +8,7 @@ The decomp project wraps all decompiled piracy checks in `#if PIRACYCHECKS` stat
|
|||
|
||||
## List of Piracy Checks
|
||||
|
||||
### init
|
||||
### bootPhase1
|
||||
|
||||
**When Called:** On power-on before the legal screen appears.
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ The decomp project wraps all decompiled piracy checks in `#if PIRACYCHECKS` stat
|
|||
|
||||
**When Called:** On every frame.
|
||||
|
||||
**What It Checks:** Checksums `init` to make sure it hasn't been modified.
|
||||
**What It Checks:** Checksums `bootPhase1` to make sure it hasn't been modified.
|
||||
|
||||
**Payload:** Writes 40 bytes of 0xff to 0x80095210. This appears to be related to sound effects but has no obvious effect.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#define LIBFILES(section) \
|
||||
build/ROMID/lib/tlb.o (section); \
|
||||
build/ROMID/lib/segments.o (section); \
|
||||
build/ROMID/lib/init.o (section); \
|
||||
build/ROMID/lib/boot.o (section); \
|
||||
build/ROMID/lib/sched.o (section); \
|
||||
build/ROMID/lib/reset.o (section); \
|
||||
build/ROMID/lib/ultra/os/maptlbrdb.o (section); \
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#define LIBFILES(section) \
|
||||
build/ROMID/lib/tlb.o (section); \
|
||||
build/ROMID/lib/segments.o (section); \
|
||||
build/ROMID/lib/init.o (section); \
|
||||
build/ROMID/lib/boot.o (section); \
|
||||
build/ROMID/lib/sched.o (section); \
|
||||
build/ROMID/lib/reset.o (section); \
|
||||
build/ROMID/lib/ultra/os/maptlbrdb.o (section); \
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#define LIBFILES(section) \
|
||||
build/ROMID/lib/tlb.o (section); \
|
||||
build/ROMID/lib/segments.o (section); \
|
||||
build/ROMID/lib/init.o (section); \
|
||||
build/ROMID/lib/boot.o (section); \
|
||||
build/ROMID/lib/sched.o (section); \
|
||||
build/ROMID/lib/reset.o (section); \
|
||||
build/ROMID/lib/ultra/os/maptlbrdb.o (section); \
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef _IN_LIB_BOOT_H
|
||||
#define _IN_LIB_BOOT_H
|
||||
#include <ultra64.h>
|
||||
|
||||
void bootPhase1(void);
|
||||
s32 bootGetMemSize(void);
|
||||
void *bootAllocateStack(s32 threadid, s32 size);
|
||||
void bootPhase2(void *arg);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#ifndef _IN_BOOT_INIT_H
|
||||
#define _IN_BOOT_INIT_H
|
||||
#include <ultra64.h>
|
||||
|
||||
void init(void);
|
||||
s32 initGetMemSize(void);
|
||||
void *allocateStack(s32 threadid, s32 size);
|
||||
void mainproc(void *arg);
|
||||
|
||||
#endif
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
extern s32 var8005dd18;
|
||||
|
||||
void mainInit(void);
|
||||
void mainEntry(void);
|
||||
void mainProc(void);
|
||||
void func0000db30(char *string, void *ptr);
|
||||
void mainLoop(void);
|
||||
void mainTick(void);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef _IN_LIB_BOOT_H
|
||||
#define _IN_LIB_BOOT_H
|
||||
#ifndef _IN_LIB_TLB_H
|
||||
#define _IN_LIB_TLB_H
|
||||
#include <ultra64.h>
|
||||
|
||||
void tlbInit(void);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include <ultra64.h>
|
||||
#include "lib/init.h"
|
||||
#include "lib/boot.h"
|
||||
#include "lib/sched.h"
|
||||
#include "constants.h"
|
||||
#include "bss.h"
|
||||
|
|
@ -400,7 +400,7 @@ void amgrHandleDoneMsg(AudioInfo *info);
|
|||
|
||||
void amgrAllocateStack(void)
|
||||
{
|
||||
g_AudioSp = allocateStack(THREAD_AUDIO, STACKSIZE_AUDIO);
|
||||
g_AudioSp = bootAllocateStack(THREAD_AUDIO, STACKSIZE_AUDIO);
|
||||
}
|
||||
|
||||
#if VERSION >= VERSION_PAL_FINAL
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include <ultra64.h>
|
||||
#include "lib/tlb.h"
|
||||
#include "lib/init.h"
|
||||
#include "lib/boot.h"
|
||||
#include "lib/reset.h"
|
||||
#include "lib/segments.h"
|
||||
#include "constants.h"
|
||||
|
|
@ -230,7 +230,7 @@ extern u16 *var800902e4;
|
|||
extern s16 var800902e8;
|
||||
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
s32 initGetMemSize(void)
|
||||
s32 bootGetMemSize(void)
|
||||
{
|
||||
return g_OsMemSize;
|
||||
}
|
||||
|
|
@ -238,7 +238,7 @@ s32 initGetMemSize(void)
|
|||
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
GLOBAL_ASM(
|
||||
glabel init
|
||||
glabel bootPhase1
|
||||
/* 16cc: 3c0e8000 */ lui $t6,0x8000
|
||||
/* 16d0: 8dce030c */ lw $t6,0x30c($t6)
|
||||
/* 16d4: 27bdffd8 */ addiu $sp,$sp,-40
|
||||
|
|
@ -347,14 +347,14 @@ glabel init
|
|||
/* 1850: 0c012078 */ jal __osSetFpcCsr
|
||||
/* 1854: 34440e80 */ ori $a0,$v0,0xe80
|
||||
/* 1858: 24040003 */ addiu $a0,$zero,0x3
|
||||
/* 185c: 0c00062b */ jal allocateStack
|
||||
/* 185c: 0c00062b */ jal bootAllocateStack
|
||||
/* 1860: 34059800 */ dli $a1,0x9800
|
||||
/* 1864: 3c108009 */ lui $s0,%hi(g_MainThread)
|
||||
/* 1868: 2610d6d0 */ addiu $s0,$s0,%lo(g_MainThread)
|
||||
/* 186c: 3c067000 */ lui $a2,%hi(mainproc)
|
||||
/* 186c: 3c067000 */ lui $a2,%hi(bootPhase2)
|
||||
/* 1870: 2409000a */ addiu $t1,$zero,0xa
|
||||
/* 1874: afa90014 */ sw $t1,0x14($sp)
|
||||
/* 1878: 24c61aa4 */ addiu $a2,$a2,%lo(mainproc)
|
||||
/* 1878: 24c61aa4 */ addiu $a2,$a2,%lo(bootPhase2)
|
||||
/* 187c: 02002025 */ or $a0,$s0,$zero
|
||||
/* 1880: 24050003 */ addiu $a1,$zero,0x3
|
||||
/* 1884: 00003825 */ or $a3,$zero,$zero
|
||||
|
|
@ -370,7 +370,7 @@ glabel init
|
|||
);
|
||||
#else
|
||||
GLOBAL_ASM(
|
||||
glabel init
|
||||
glabel bootPhase1
|
||||
/* 1720: 3c040003 */ lui $a0,0x3
|
||||
/* 1724: 3c0e0004 */ lui $t6,0x4
|
||||
/* 1728: 3c0f0004 */ lui $t7,0x4
|
||||
|
|
@ -460,7 +460,7 @@ glabel init
|
|||
/* 1868: 240b4040 */ li $t3,0x4040
|
||||
/* 186c: a46b0000 */ sh $t3,0x0($v1)
|
||||
/* 1870: 24040003 */ li $a0,0x3
|
||||
/* 1874: 0c000631 */ jal allocateStack
|
||||
/* 1874: 0c000631 */ jal bootAllocateStack
|
||||
/* 1878: 34059800 */ li $a1,0x9800
|
||||
/* 187c: 3c108009 */ lui $s0,0x8009
|
||||
/* 1880: 2610fd00 */ addiu $s0,$s0,-768
|
||||
|
|
@ -494,7 +494,7 @@ glabel init
|
|||
*/
|
||||
// Mismatch: Goal uses s0 for dst in some places.
|
||||
// Also uses way less stack somehow.
|
||||
//void init(void)
|
||||
//void bootPhase1(void)
|
||||
//{
|
||||
// u32 datacomplen;
|
||||
// u32 inflatelen;
|
||||
|
|
@ -572,13 +572,13 @@ glabel init
|
|||
//#endif
|
||||
//
|
||||
// // Create and start the main thread
|
||||
// osCreateThread(&g_MainThread, THREAD_MAIN, mainproc, NULL, allocateStack(THREAD_MAIN, STACKSIZE_MAIN), THREADPRI_MAIN);
|
||||
// osCreateThread(&g_MainThread, THREAD_MAIN, bootPhase2, NULL, bootAllocateStack(THREAD_MAIN, STACKSIZE_MAIN), THREADPRI_MAIN);
|
||||
// osStartThread(&g_MainThread);
|
||||
//}
|
||||
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
GLOBAL_ASM(
|
||||
glabel allocateStack
|
||||
glabel bootAllocateStack
|
||||
/* 18ac: 3c098006 */ lui $t1,%hi(g_StackAllocatedPos)
|
||||
/* 18b0: 2529ce48 */ addiu $t1,$t1,%lo(g_StackAllocatedPos)
|
||||
/* 18b4: 8d230000 */ lw $v1,0x0($t1)
|
||||
|
|
@ -635,7 +635,7 @@ glabel allocateStack
|
|||
// Mismatch:
|
||||
// i is stored in a3 but should be t0
|
||||
// The value written to ptr[i] is stored in t0 but should be a2
|
||||
//void *allocateStack(s32 threadid, s32 size)
|
||||
//void *bootAllocateStack(s32 threadid, s32 size)
|
||||
//{
|
||||
// u8 *ptr8;
|
||||
// u32 *ptr32;
|
||||
|
|
@ -668,7 +668,7 @@ glabel allocateStack
|
|||
//}
|
||||
#else
|
||||
GLOBAL_ASM(
|
||||
glabel allocateStack
|
||||
glabel bootAllocateStack
|
||||
/* 18c4: 3c0a8006 */ lui $t2,0x8006
|
||||
/* 18c8: 254ae5c8 */ addiu $t2,$t2,-6712
|
||||
/* 18cc: 8d430000 */ lw $v1,0x0($t2)
|
||||
|
|
@ -718,7 +718,7 @@ glabel allocateStack
|
|||
#endif
|
||||
|
||||
#if VERSION < VERSION_NTSC_1_0
|
||||
s32 initGetMemSize(void)
|
||||
s32 bootGetMemSize(void)
|
||||
{
|
||||
return g_OsMemSize;
|
||||
}
|
||||
|
|
@ -737,19 +737,19 @@ void idleproc(void *data)
|
|||
while (true);
|
||||
}
|
||||
|
||||
void idleCreateThread(void)
|
||||
void bootCreateIdleThread(void)
|
||||
{
|
||||
osCreateThread(&g_IdleThread, THREAD_IDLE, idleproc, NULL, allocateStack(THREAD_IDLE, STACKSIZE_IDLE), THREADPRI_IDLE);
|
||||
osCreateThread(&g_IdleThread, THREAD_IDLE, idleproc, NULL, bootAllocateStack(THREAD_IDLE, STACKSIZE_IDLE), THREADPRI_IDLE);
|
||||
osStartThread(&g_IdleThread);
|
||||
}
|
||||
|
||||
void rmonCreateThread(void)
|
||||
void bootCreateRmonThread(void)
|
||||
{
|
||||
osCreateThread(&g_RmonThread, THREAD_RMON, rmonproc, NULL, allocateStack(THREAD_RMON, STACKSIZE_RMON), THREADPRI_RMON);
|
||||
osCreateThread(&g_RmonThread, THREAD_RMON, rmonproc, NULL, bootAllocateStack(THREAD_RMON, STACKSIZE_RMON), THREADPRI_RMON);
|
||||
osStartThread(&g_RmonThread);
|
||||
}
|
||||
|
||||
void schedCreateThread(void)
|
||||
void bootCreateSchedThread(void)
|
||||
{
|
||||
osCreateMesgQueue(&var8008db30, &var8008db48, 32);
|
||||
|
||||
|
|
@ -763,20 +763,20 @@ void schedCreateThread(void)
|
|||
g_SchedCmdQ = osScGetCmdQ(&g_SchedThread);
|
||||
}
|
||||
|
||||
void mainproc(void *arg)
|
||||
void bootPhase2(void *arg)
|
||||
{
|
||||
idleCreateThread();
|
||||
bootCreateIdleThread();
|
||||
func00013750();
|
||||
func00013710();
|
||||
rmonCreateThread();
|
||||
bootCreateRmonThread();
|
||||
|
||||
if (argsParseDebugArgs()) {
|
||||
osStopThread(NULL);
|
||||
}
|
||||
|
||||
osSetThreadPri(0, THREADPRI_MAIN);
|
||||
schedCreateThread();
|
||||
mainEntry();
|
||||
bootCreateSchedThread();
|
||||
mainProc();
|
||||
}
|
||||
|
||||
#if VERSION < VERSION_NTSC_1_0
|
||||
|
|
@ -38,7 +38,7 @@ glabel func000070d0
|
|||
/* 70fc: afb10020 */ sw $s1,0x20($sp)
|
||||
/* 7100: 0c00222c */ jal rzipInflateFixed
|
||||
/* 7104: a030ae28 */ sb $s0,%lo(var8008ae28)($at)
|
||||
/* 7108: 0c0005b0 */ jal initGetMemSize
|
||||
/* 7108: 0c0005b0 */ jal bootGetMemSize
|
||||
/* 710c: 00000000 */ nop
|
||||
/* 7110: 3c010040 */ lui $at,0x40
|
||||
/* 7114: 34210001 */ ori $at,$at,0x1
|
||||
|
|
|
|||
|
|
@ -411,7 +411,7 @@ glabel mainInit
|
|||
/* d40c: 8dd9001c */ lw $t9,0x1c($t6)
|
||||
/* d410: 8dc10018 */ lw $at,0x18($t6)
|
||||
/* d414: adb9001c */ sw $t9,0x1c($t5)
|
||||
/* d418: 0c0005b0 */ jal initGetMemSize
|
||||
/* d418: 0c0005b0 */ jal bootGetMemSize
|
||||
/* d41c: ada10018 */ sw $at,0x18($t5)
|
||||
/* d420: 3c010040 */ lui $at,0x40
|
||||
/* d424: 34210001 */ ori $at,$at,0x1
|
||||
|
|
@ -816,7 +816,7 @@ glabel mainInit
|
|||
/* d6d4: 8dd9001c */ lw $t9,0x1c($t6)
|
||||
/* d6d8: 8dc10018 */ lw $at,0x18($t6)
|
||||
/* d6dc: adb9001c */ sw $t9,0x1c($t5)
|
||||
/* d6e0: 0c0005b0 */ jal initGetMemSize
|
||||
/* d6e0: 0c0005b0 */ jal bootGetMemSize
|
||||
/* d6e4: ada10018 */ sw $at,0x18($t5)
|
||||
/* d6e8: 3c010040 */ lui $at,0x40
|
||||
/* d6ec: 34210001 */ ori $at,$at,0x1
|
||||
|
|
@ -1537,7 +1537,7 @@ const char var70053aa0[] = " -ml0 -me0 -mgfx100 -mvtx50 -mt700 -ma400";
|
|||
// u8 sp50[5120];
|
||||
// u32 stack;
|
||||
//
|
||||
// if (initGetMemSize() <= 4 * 1024 * 1024) {
|
||||
// if (bootGetMemSize() <= 4 * 1024 * 1024) {
|
||||
// iVar5 = 0x803f50b8 - var8005cf84 * 8;
|
||||
// iVar5 -= 548864 * 2;
|
||||
// iVar5 = iVar5 - (iVar5 & 0x1fff) - 0x1c80;
|
||||
|
|
@ -1719,7 +1719,7 @@ glabel func0000e010nb
|
|||
);
|
||||
#endif
|
||||
|
||||
void mainEntry(void)
|
||||
void mainProc(void)
|
||||
{
|
||||
mainInit();
|
||||
rdpInit();
|
||||
|
|
|
|||
|
|
@ -85,13 +85,13 @@ void memInit(u32 heapstart, u32 heaplen)
|
|||
|
||||
// If 8MB, reserve the entire expansion pak for additional mempool 4
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
extraend = 0x80000000 + initGetMemSize();
|
||||
extraend = 0x80000000 + bootGetMemSize();
|
||||
#else
|
||||
extraend = 0x80000000 + osGetMemSize();
|
||||
#endif
|
||||
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
if (initGetMemSize() > 4 * 1024 * 1024)
|
||||
if (bootGetMemSize() > 4 * 1024 * 1024)
|
||||
#else
|
||||
if (osGetMemSize() > 4 * 1024 * 1024)
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include <ultra64.h>
|
||||
#include "lib/init.h"
|
||||
#include "lib/boot.h"
|
||||
#include "lib/sched.h"
|
||||
#include "constants.h"
|
||||
#include "game/game_0e0770.h"
|
||||
|
|
@ -141,7 +141,7 @@ void osCreateScheduler(OSSched *sc, void *stack, u8 mode, u32 numFields)
|
|||
|
||||
osViSetEvent(&sc->interruptQ, (OSMesg)VIDEO_MSG, numFields);
|
||||
osCreateLog();
|
||||
osCreateThread(sc->thread, THREAD_SCHED, &__scMain, sc, allocateStack(THREAD_SCHED, STACKSIZE_SCHED), THREADPRI_SCHED);
|
||||
osCreateThread(sc->thread, THREAD_SCHED, &__scMain, sc, bootAllocateStack(THREAD_SCHED, STACKSIZE_SCHED), THREADPRI_SCHED);
|
||||
osStartThread(sc->thread);
|
||||
}
|
||||
|
||||
|
|
@ -322,8 +322,8 @@ void __scHandleRetrace(OSSched *sc)
|
|||
#if PIRACYCHECKS
|
||||
{
|
||||
u32 checksum = 0;
|
||||
s32 *end = (s32 *)&allocateStack;
|
||||
s32 *ptr = (s32 *)&init;
|
||||
s32 *end = (s32 *)&bootAllocateStack;
|
||||
s32 *ptr = (s32 *)&bootPhase1;
|
||||
s32 i;
|
||||
|
||||
while (ptr < end) {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ glabel var8008d268
|
|||
.text
|
||||
|
||||
/**
|
||||
* Sets up TLB index 0 (0x70000000), then calls init.
|
||||
* Sets up TLB index 0 (0x70000000), then calls bootPhase1.
|
||||
*/
|
||||
glabel tlbInit
|
||||
lui $t0, 0x7f
|
||||
|
|
@ -67,8 +67,8 @@ glabel tlbInit
|
|||
nop
|
||||
nop
|
||||
nop
|
||||
lui $t0, %hi(init)
|
||||
addiu $t0, $t0, %lo(init)
|
||||
lui $t0, %hi(bootPhase1)
|
||||
addiu $t0, $t0, %lo(bootPhase1)
|
||||
jr $t0
|
||||
nop
|
||||
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ class Tool:
|
|||
|
||||
self.fd = open(sys.argv[1], 'rb+')
|
||||
|
||||
self.patch(algo01, '__scHandleRetrace', 'init')
|
||||
self.patch(algo01, '__scHandleRetrace', 'bootPhase1')
|
||||
self.patch(algo02, 'cheatMenuHandleDialog', '__scHandleRetrace')
|
||||
self.patch(algo03, 'propobjHandlePickupByAibot', 'func0f08e2ac')
|
||||
self.patch(algo04, 'chrUncloak', 'propobjHandlePickupByAibot')
|
||||
|
|
|
|||
Loading…
Reference in New Issue