#include <os.h>
#include <dvd.h>
static void *Header[0x20 / sizeof(void *)];
static void *SaveStart;
static void *SaveEnd;
static BOOL Prepared;
void Run(register Event callback)
{
OSDisableInterrupts();
ICFlashInvalidate();
__sync();
__isync();
asm {
mtlr callback
blr
}
}
static void Callback(void)
{
Prepared = TRUE;
}
#pragma push
asm void __OSReboot(u32 resetCode, BOOL forceMenu)
{
nofralloc
mflr r0
stw r0, 4(r1)
stwu r1, -0x348(r1)
stw r31, 0x344(r1)
stw r30, 0x340(r1)
stw r29, 0x33c(r1)
mr r29, r3
lis r3, Header@ha
addi r30, r3, Header@l
bl OSDisableInterrupts
lwz r5, SaveStart(r13)
lis r31, 0x817FFFFC@ha
li r3, 0
lwz r0, SaveEnd(r13)
lis r4, 0x812FDFF0@ha
li r7, 1
stw r29, 0x817FFFFC@l(r31)
lis r6, 0x800030E2@ha
stw r3, -8(r31)
addi r3, r1, 0x70
stb r7, 0x800030E2@l(r6)
stw r5, 0x812FDFF0@l(r4)
stw r0, -0x2014(r4)
bl OSClearContext
addi r3, r1, 0x70
bl OSSetCurrentContext
bl DVDInit
li r3, 1
bl DVDSetAutoInvalidation
lis r3, Callback@ha
addi r3, r3, Callback@l
bl __DVDPrepareResetAsync
bl DVDCheckDisk
cmpwi r3, 0
bne lbl_803481D8
lwz r3, -4(r31)
bl __OSDoHotReset
lbl_803481D8:
li r3, -32
bl __OSMaskInterrupts
li r3, 0x400
bl __OSUnmaskInterrupts
bl OSEnableInterrupts
b lbl_803481F0
lbl_803481F0:
b lbl_803481F4
lbl_803481F4:
lwz r0, Prepared(r13)
cmpwi r0, 0
beq lbl_803481F4
mr r4, r30
addi r3, r1, 0x40
li r5, 0x20
li r6, 0x2440
li r7, 0
bl DVDReadAbsAsyncForBS
lis r31, 0x8180
b lbl_80348220
lbl_80348220:
b lbl_80348224
lbl_80348224:
lwz r0, 0x4c(r1)
cmpwi r0, 1
beq lbl_80348224
bge lbl_80348244
cmpwi r0, -1
beq lbl_80348250
bge lbl_8034825C
b lbl_80348224
lbl_80348244:
cmpwi r0, 0xc
bge lbl_80348224
b lbl_80348250
lbl_80348250:
lwz r3, -4(r31)
bl __OSDoHotReset
b lbl_80348224
lbl_8034825C:
lwz r3, 0x18(r30)
lwz r4, 0x14(r30)
addi r0, r3, 0x1f
addi r4, r4, 0x20
rlwinm r30, r0, 0, 0, 0x1a
b lbl_80348274
lbl_80348274:
b lbl_80348278
lbl_80348278:
lwz r0, Prepared(r13)
cmpwi r0, 0
beq lbl_80348278
mr r5, r30
addi r3, r1, 0x10
addi r6, r4, 0x2440
lis r4, 0x8130
li r7, 0
bl DVDReadAbsAsyncForBS
lis r31, 0x8180
b lbl_803482A4
lbl_803482A4:
b lbl_803482A8
lbl_803482A8:
lwz r0, 0x1c(r1)
cmpwi r0, 1
beq lbl_803482A8
bge lbl_803482C8
cmpwi r0, -1
beq lbl_803482D4
bge lbl_803482E0
b lbl_803482A8
lbl_803482C8:
cmpwi r0, 0xc
bge lbl_803482A8
b lbl_803482D4
lbl_803482D4:
lwz r3, -4(r31)
bl __OSDoHotReset
b lbl_803482A8
lbl_803482E0:
lis r3, 0x8130
mr r4, r30
bl ICInvalidateRange
lis r3, 0x8130
bl Run
lwz r0, 0x34c(r1)
lwz r31, 0x344(r1)
lwz r30, 0x340(r1)
mtlr r0
lwz r29, 0x33c(r1)
addi r1, r1, 0x348
blr
}
#pragma pop