Match and link fstload.c

This commit is contained in:
Phillip Stephens 2022-10-21 23:59:50 -07:00
parent c4e4352c4f
commit 1ddf72b492
5 changed files with 91 additions and 20 deletions

View File

@ -18,7 +18,10 @@
"gba.h": "c",
"gbapriv.h": "c",
"os.h": "c",
"sipriv.h": "c"
"sipriv.h": "c",
"dvd_regs.h": "c",
"dvd.h": "c",
"dvdpriv.h": "c"
},
"files.autoSave": "onFocusChange",
"files.insertFinalNewline": true,

View File

@ -9,11 +9,11 @@ lbl_80540C58:
.section .sbss
.balign 8
lbl_805A9828:
status:
.skip 0x4
lbl_805A982C:
bb2:
.skip 0x4
lbl_805A9830:
idTmp:
.skip 0x8
.section .sdata
@ -51,6 +51,7 @@ lbl_803F0578:
.section .text, "ax"
.global cb
cb:
/* 80374E6C 00371DCC 7C 08 02 A6 */ mflr r0
/* 80374E70 00371DD0 2C 03 00 00 */ cmpwi r3, 0
@ -59,7 +60,7 @@ cb:
/* 80374E7C 00371DDC 93 E1 00 14 */ stw r31, 0x14(r1)
/* 80374E80 00371DE0 3B E4 00 00 */ addi r31, r4, 0
/* 80374E84 00371DE4 40 81 00 7C */ ble lbl_80374F00
/* 80374E88 00371DE8 80 0D AC 68 */ lwz r0, lbl_805A9828@sda21(r13)
/* 80374E88 00371DE8 80 0D AC 68 */ lwz r0, status@sda21(r13)
/* 80374E8C 00371DEC 2C 00 00 01 */ cmpwi r0, 1
/* 80374E90 00371DF0 41 82 00 3C */ beq lbl_80374ECC
/* 80374E94 00371DF4 40 80 00 9C */ bge lbl_80374F30
@ -68,9 +69,9 @@ cb:
/* 80374EA0 00371E00 48 00 00 90 */ b lbl_80374F30
lbl_80374EA4:
/* 80374EA4 00371E04 38 00 00 01 */ li r0, 1
/* 80374EA8 00371E08 80 8D AC 6C */ lwz r4, lbl_805A982C@sda21(r13)
/* 80374EA8 00371E08 80 8D AC 6C */ lwz r4, bb2@sda21(r13)
/* 80374EAC 00371E0C 3C 60 80 37 */ lis r3, cb@ha
/* 80374EB0 00371E10 90 0D AC 68 */ stw r0, lbl_805A9828@sda21(r13)
/* 80374EB0 00371E10 90 0D AC 68 */ stw r0, status@sda21(r13)
/* 80374EB4 00371E14 38 E3 4E 6C */ addi r7, r3, cb@l
/* 80374EB8 00371E18 38 7F 00 00 */ addi r3, r31, 0
/* 80374EBC 00371E1C 38 A0 00 20 */ li r5, 0x20
@ -79,8 +80,8 @@ lbl_80374EA4:
/* 80374EC8 00371E28 48 00 00 68 */ b lbl_80374F30
lbl_80374ECC:
/* 80374ECC 00371E2C 38 00 00 02 */ li r0, 2
/* 80374ED0 00371E30 80 CD AC 6C */ lwz r6, lbl_805A982C@sda21(r13)
/* 80374ED4 00371E34 90 0D AC 68 */ stw r0, lbl_805A9828@sda21(r13)
/* 80374ED0 00371E30 80 CD AC 6C */ lwz r6, bb2@sda21(r13)
/* 80374ED4 00371E34 90 0D AC 68 */ stw r0, status@sda21(r13)
/* 80374ED8 00371E38 3C 60 80 37 */ lis r3, cb@ha
/* 80374EDC 00371E3C 38 E3 4E 6C */ addi r7, r3, cb@l
/* 80374EE0 00371E40 80 A6 00 08 */ lwz r5, 8(r6)
@ -97,10 +98,10 @@ lbl_80374F00:
/* 80374F08 00371E68 2C 03 FF FC */ cmpwi r3, -4
/* 80374F0C 00371E6C 40 82 00 24 */ bne lbl_80374F30
/* 80374F10 00371E70 38 00 00 00 */ li r0, 0
/* 80374F14 00371E74 90 0D AC 68 */ stw r0, lbl_805A9828@sda21(r13)
/* 80374F14 00371E74 90 0D AC 68 */ stw r0, status@sda21(r13)
/* 80374F18 00371E78 4B FF F1 A9 */ bl DVDReset
/* 80374F1C 00371E7C 3C 60 80 37 */ lis r3, cb@ha
/* 80374F20 00371E80 80 8D AC 70 */ lwz r4, lbl_805A9830@sda21(r13)
/* 80374F20 00371E80 80 8D AC 70 */ lwz r4, idTmp@sda21(r13)
/* 80374F24 00371E84 38 A3 4E 6C */ addi r5, r3, cb@l
/* 80374F28 00371E88 38 7F 00 00 */ addi r3, r31, 0
/* 80374F2C 00371E8C 4B FF EB 75 */ bl DVDReadDiskID
@ -128,11 +129,11 @@ __fstLoad:
/* 80374F74 00371ED4 38 03 00 1F */ addi r0, r3, 0x1f
/* 80374F78 00371ED8 54 83 00 34 */ rlwinm r3, r4, 0, 0, 0x1a
/* 80374F7C 00371EDC 54 00 00 34 */ rlwinm r0, r0, 0, 0, 0x1a
/* 80374F80 00371EE0 90 6D AC 70 */ stw r3, lbl_805A9830@sda21(r13)
/* 80374F84 00371EE4 90 0D AC 6C */ stw r0, lbl_805A982C@sda21(r13)
/* 80374F80 00371EE0 90 6D AC 70 */ stw r3, idTmp@sda21(r13)
/* 80374F84 00371EE4 90 0D AC 6C */ stw r0, bb2@sda21(r13)
/* 80374F88 00371EE8 4B FF F1 39 */ bl DVDReset
/* 80374F8C 00371EEC 3C 60 80 54 */ lis r3, lbl_80540C58@ha
/* 80374F90 00371EF0 80 8D AC 70 */ lwz r4, lbl_805A9830@sda21(r13)
/* 80374F90 00371EF0 80 8D AC 70 */ lwz r4, idTmp@sda21(r13)
/* 80374F94 00371EF4 3C A0 80 37 */ lis r5, cb@ha
/* 80374F98 00371EF8 38 63 0C 58 */ addi r3, r3, lbl_80540C58@l
/* 80374F9C 00371EFC 38 A5 4E 6C */ addi r5, r5, cb@l
@ -141,17 +142,17 @@ lbl_80374FA4:
/* 80374FA4 00371F04 4B FF F1 AD */ bl DVDGetDriveStatus
/* 80374FA8 00371F08 2C 03 00 00 */ cmpwi r3, 0
/* 80374FAC 00371F0C 40 82 FF F8 */ bne lbl_80374FA4
/* 80374FB0 00371F10 80 6D AC 6C */ lwz r3, lbl_805A982C@sda21(r13)
/* 80374FB0 00371F10 80 6D AC 6C */ lwz r3, bb2@sda21(r13)
/* 80374FB4 00371F14 3F A0 80 00 */ lis r29, 0x80000000@ha
/* 80374FB8 00371F18 3F C0 80 00 */ lis r30, 0x80000038@ha
/* 80374FBC 00371F1C 80 03 00 10 */ lwz r0, 0x10(r3)
/* 80374FC0 00371F20 38 7D 00 00 */ addi r3, r29, 0x80000000@l
/* 80374FC4 00371F24 38 A0 00 20 */ li r5, 0x20
/* 80374FC8 00371F28 90 1E 00 38 */ stw r0, 0x80000038@l(r30)
/* 80374FCC 00371F2C 80 8D AC 6C */ lwz r4, lbl_805A982C@sda21(r13)
/* 80374FCC 00371F2C 80 8D AC 6C */ lwz r4, bb2@sda21(r13)
/* 80374FD0 00371F30 80 04 00 0C */ lwz r0, 0xc(r4)
/* 80374FD4 00371F34 90 1E 00 3C */ stw r0, 0x3c(r30)
/* 80374FD8 00371F38 80 8D AC 70 */ lwz r4, lbl_805A9830@sda21(r13)
/* 80374FD8 00371F38 80 8D AC 70 */ lwz r4, idTmp@sda21(r13)
/* 80374FDC 00371F3C 4B C8 E4 B5 */ bl memcpy
/* 80374FE0 00371F40 38 6D 9E F8 */ addi r3, r13, lbl_805A8AB8@sda21
/* 80374FE4 00371F44 4C C6 31 82 */ crclr 6
@ -196,7 +197,7 @@ lbl_8037506C:
/* 80375078 00371FD8 38 6D 9E F8 */ addi r3, r13, lbl_805A8AB8@sda21
/* 8037507C 00371FDC 4C C6 31 82 */ crclr 6
/* 80375080 00371FE0 48 00 A9 2D */ bl OSReport
/* 80375084 00371FE4 80 6D AC 6C */ lwz r3, lbl_805A982C@sda21(r13)
/* 80375084 00371FE4 80 6D AC 6C */ lwz r3, bb2@sda21(r13)
/* 80375088 00371FE8 80 63 00 10 */ lwz r3, 0x10(r3)
/* 8037508C 00371FEC 48 00 97 15 */ bl OSSetArenaHi
/* 80375090 00371FF0 80 01 00 64 */ lwz r0, 0x64(r1)

View File

@ -777,7 +777,7 @@ LIBS = [
"Dolphin/dvd/dvderror",
["Dolphin/dvd/dvdidutils", True],
"Dolphin/dvd/dvdfatal",
"Dolphin/dvd/fstload",
["Dolphin/dvd/fstload", True],
],
},
{

View File

@ -660,7 +660,7 @@ DVD_FILES :=\
$(BUILD_DIR)/asm/Dolphin/dvd/dvderror.o\
$(BUILD_DIR)/src/Dolphin/dvd/dvdidutils.ep.o\
$(BUILD_DIR)/asm/Dolphin/dvd/dvdfatal.o\
$(BUILD_DIR)/asm/Dolphin/dvd/fstload.o
$(BUILD_DIR)/src/Dolphin/dvd/fstload.ep.o
GX_FILES :=\
$(BUILD_DIR)/asm/Dolphin/gx/GXInit.o\

67
src/Dolphin/dvd/fstload.c Normal file
View File

@ -0,0 +1,67 @@
#include <dolphin/DVDPriv.h>
#include <dolphin/dvd.h>
#include <dolphin/dvd_regs.h>
#include <dolphin/os.h>
#include <dolphin/os/OSBootInfo.h>
#include <string.h>
static s32 status = 0;
static u8 bb2Buf[OSRoundUp32B(sizeof(DVDBB2)) + 31];
static DVDBB2* bb2 = 0;
static DVDDiskID* idTmp = NULL;
static void cb(s32 result, DVDCommandBlock* block) {
if (result > 0) {
switch (status) {
case 0:
status = 1;
DVDReadAbsAsyncForBS(block, bb2, OSRoundUp32B(sizeof(bb2)), 0x420, cb);
break;
case 1:
status = 2;
DVDReadAbsAsyncForBS(block, bb2->FSTAddress, OSRoundUp32B(bb2->FSTLength), bb2->FSTPosition,
cb);
}
} else if (result == -1) {
} else if (result == -4) {
status = 0;
DVDReset();
DVDReadDiskID(block, idTmp, cb);
}
}
void __fstLoad() {
OSBootInfo* bootInfo;
DVDDiskID* id;
u8 idTmpBuf[sizeof(DVDDiskID) + 31];
static DVDCommandBlock block;
void* arenaHi;
arenaHi = OSGetArenaHi();
bootInfo = (OSBootInfo*)OSPhysicalToCached(0);
idTmp = (DVDDiskID*)(OSRoundUp32B(idTmpBuf));
bb2 = (DVDBB2*)(OSRoundUp32B(bb2Buf));
DVDReset();
DVDReadDiskID(&block, idTmp, cb);
while (DVDGetDriveStatus() != 0);
bootInfo->FSTLocation = bb2->FSTAddress;
bootInfo->FSTMaxLength = bb2->FSTMaxLength;
id = &bootInfo->DVDDiskID;
memcpy(id, idTmp, sizeof(DVDDiskID));
OSReport("\n");
OSReport(" Game Name ... %c%c%c%c\n", id->gameName[0], id->gameName[1], id->gameName[2],
id->gameName[3]);
OSReport(" Company ..... %c%c\n", id->company[0], id->company[1]);
OSReport(" Disk # ...... %d\n", id->diskNumber);
OSReport(" Game ver .... %d\n", id->gameVersion);
OSReport(" Streaming ... %s\n", (id->streaming == 0) ? "OFF" : "ON");
OSReport("\n");
OSSetArenaHi(bb2->FSTAddress);
}