xsomething progress (#20)

* xsomething progress

* couple changes

---------

Co-authored-by: Ethan Roseman <ethteck@gmail.com>
This commit is contained in:
Noah McQueen 2023-11-30 09:54:03 -07:00 committed by GitHub
parent 8edcec76f3
commit 1e765933b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 230 additions and 57 deletions

View File

@ -285,13 +285,14 @@ segments:
- [0x144BF0, asm]
- [0x146BD0, c, xmonitor]
- [0x1477F8, asm]
- [0x14A438, c, xgoober]
- [0x14A4D8, asm]
- [0x14A5D8, c, xsomething]
- [0x14AB08, asm]
- [0x14A090, c, xsomething]
###########
# Library #
###########
# ??? - the following 3 have 0x10 file alignment and 0x4 (no) function alignment within files
- [0x14AB28, asm]
- [0x14B880, asm]
- [0x14BA00, asm]
# libc.a
- [0x14BD50, asm, libc/assert]
- [0x14BD88, asm, libc/bsearch]
@ -523,9 +524,7 @@ segments:
- [0x38B400, rodata, 144BF0]
- [0x38B450, .rodata, xmonitor]
- [0x38B468, rodata, 1477F8]
# - [0x38B558, .rodata, xgoober]
- [0x38B560, rodata, 14A4D8]
- [0x38B578, .rodata, xsomething]
- [0x38B518, .rodata, xsomething]
- [0x38B598, rodata, libc/assert]
- [0x38B5C8, rodata, libc/ctype_]
- [0x38B6D0, rodata, libc/impure]

View File

@ -184,7 +184,7 @@ void func_00120108(XCrown* arg0) {
s32 fd;
s32 nbyte;
fd = sceOpen("pfs0:kingdom.img", 1);
fd = sceOpen("pfs0:kingdom.img", SCE_RDONLY);
cond = FALSE;
if (fd < 0 || D_002C2094 & 0x2000) {

View File

@ -1,54 +1,213 @@
#include "common.h"
#include "io.h"
#include "sifdev.h"
#include "gcc/stdio.h"
#include "gcc/string.h"
#include "sdk/libcdvd.h"
#include "eekernel.h"
typedef char* (*XWhat)(void);
typedef s32 (*XHuh)(s32);
typedef struct XThingy {
/* 0x00 */ char unk_00[0x4];
/* 0x04 */ char* (*unk_04)(void);
/* 0x08 */ char unk_08[0x8];
/* 0x10 */ s32 unk_10;
/* 0x00 */ XWhat unk_00;
/* 0x04 */ XWhat unk_04;
/* 0x04 */ XWhat unk_08;
/* 0x04 */ XWhat unk_0C;
/* 0x10 */ s32 bIsMounted;
} XThingy;
s32 func_0024A010(void);
char* func_0024A3A8(void);
s32 func_0024A3B8(void);
s32 func_0024A458(void);
s32 func_0024A4A8(void);
s32 func_0024A558(void);
void func_0024A630(s32);
s32 func_0024A630(s32);
s32 func_0024A780(char*, char*);
s32 func_0024A850(s32*);
extern volatile u8 D_002C1EB8;
extern s32 D_004642E8; // file length
extern s32 D_004642EC;
extern s32 D_004642F0;
extern s32 D_004642F4;
extern s32 D_004642F8;
extern char D_00464300[];
extern char D_00464308[];
extern s32 D_00464330;
extern char D_00464320[];
extern char D_00464330[];
extern char D_00464340[];
extern s32 D_00464354;
extern s32 D_00464358;
extern s32 D_0046435C;
extern XThingy D_00464360;
extern s32 D_00464384;
extern char D_0048B4F0[]; // device name
extern s32 D_0048DB00; // gp0 value
extern char D_00663A90[0x1000];
s32 func_0024A010() {
return D_004642EC;
}
INCLUDE_ASM(const s32, "xsomething", func_0024A020);
void func_0024A140(s32 arg0) {
if (0 < arg0) {
do {
D_004642F8++;
arg0--;
} while (arg0 != 0);
}
}
s32 func_0024A178() {
return D_004642F8;
}
void func_0024A188(s32 arg0) {
int iVar1;
int stat[4];
do {
WaitSema(arg0);
D_002C1EB8 = D_002C1EB8 & 0xE7 | 0x10;
iVar1 = func_0024A010();
if (iVar1 != 0) {
sceDevctl("pfs:", PDIOC_CLOSEALL, NULL, 0, NULL, 0);
}
while (sceDevctl("hdd:", HDIOC_DEV9OFF, NULL, 0, NULL, 0) < 0) {
func_0024A140(100000);
}
while (sceCdPowerOff(stat) == 0) {
func_0024A140(100000);
}
D_002C1EB8 |= 0x10 | 0x8;
D_004642F0++;
} while (TRUE);
}
void func_0024A278(s32 arg0) {
D_002C1EB8 = D_002C1EB8 & ~(0x10 | 0x8) | 0x8;
if (func_0024A010() != 0) {
iSignalSema(arg0);
}
}
s32* func_0024A2D0() {
struct ThreadParam threadParam;
void* sema;
struct SemaParam semaParam;
int thread;
semaParam.maxCount = 1;
semaParam.initCount = 0;
semaParam.option = 0;
sema = CreateSema(&semaParam);
threadParam.initPriority = 1;
threadParam.stackSize = sizeof(D_00663A90);
threadParam.gpReg = &D_0048DB00;
threadParam.entry = func_0024A188;
threadParam.stack = D_00663A90;
thread = CreateThread(&threadParam);
StartThread(thread, sema);
return sceCdPOffCallback(func_0024A278, sema);
}
char* func_0024A368() {
// return "128M";
return D_00464300;
}
char* func_0024A378(void) {
// return "PP.SLPS-25105.0.KINGDOM";
return D_00464308;
}
char* func_0024A388(void) {
// return "haneman0";
return D_00464320;
}
char* func_0024A398(void) {
// return "mangan01";
return D_00464330;
}
char* func_0024A3A8() {
// return "pfs0:kingdom.img";
return D_00464340;
}
s32 func_0024A3B8() {
char* pcVar1;
char* pcVar2;
char blkdevname[128];
if (D_00464360.bIsMounted == FALSE) {
pcVar1 = D_00464360.unk_04();
pcVar2 = D_00464360.unk_08();
sprintf(blkdevname, "hdd0:%s,%s", pcVar1, pcVar2);
if (sceMount("pfs0:", blkdevname, SCE_MT_RDWR, NULL, 0) < 0) {
return TRUE;
}
D_00464360.bIsMounted = TRUE;
}
return FALSE;
}
s32 func_0024A458() {
if (D_00464360.bIsMounted != FALSE) {
if (sceUmount("pfs0:") == 0) {
D_00464360.bIsMounted = FALSE;
return FALSE;
}
}
return TRUE;
}
s32 func_0024A4A8() {
char* filename;
s32 fd;
u64 offset;
s32 ret;
D_004642F4 = 90;
filename = func_0024A3A8();
fd = sceOpen(filename, SCE_RDONLY);
D_004642F4 = 100;
ret = TRUE;
if (fd >= 0) {
offset = sceLseek64(fd, 0, 2);
D_004642F4 = 110;
sceClose(fd);
D_004642F4 = 120;
ret = D_004642E8; // seems fake?
ret = TRUE;
if ((u32)D_004642E8 == offset) {
ret = FALSE;
}
}
return ret;
}
s32 func_0024A558(void) {
return sceDevctl(D_0048B4F0, 0x4807, 0, 0, 0, 0);
return sceDevctl("hdd0:", HDIOC_STATUS, NULL, 0, NULL, 0);
}
s32 func_0024A588(char* devname, s32 arg1) {
s32 sp0;
s32 bufp;
sceDevctl(devname, 0x4802, NULL, 0, 0, 0);
sceDevctl(devname, HDIOC_TOTALSECTOR, NULL, 0, 0, 0);
D_004642F4 = 60;
sp0 = 0;
bufp = NULL;
if (sceDevctl(devname, 0x480A, NULL, 0, &sp0, 4) != 0) {
if (sceDevctl(devname, HDIOC_FREESECTOR, NULL, 0, &bufp, 4) != 0) {
return FALSE;
}
D_004642F4 = 70;
if ((s32)((u32) sp0 >> 0x12) < arg1) {
if ((s32)((u32)bufp >> 0x12) < arg1) {
return FALSE;
}
return TRUE;
@ -58,40 +217,40 @@ s32 func_0024A620(void) {
return D_00464354;
}
INCLUDE_ASM(const s32, "xsomething", func_0024A630);
s32 func_0024A630(s32 arg0) {
char filename[0x40];
s32 fd;
int val;
// void func_0024A630(s32 arg0) {
// char filename[0x40];
// s32 temp_20;
// s32 fd;
// s32 temp_2_2;
// s32 var_17;
// s32 temp;
s32 temp = 0;
s32 mounted = D_00464360.bIsMounted;
// var_17 = 0;
// temp_20 = D_00464360.unk_10;
// D_00464354 = 0;
// if (temp_20 != 0) {
// func_0024A458();
// }
// D_004642F4 = 40;
// sprintf(filename, "hdd0:%s,,%s", D_00464360.unk_04(), &D_00464330);
// fd = sceOpen(filename, 1);
// if (fd >= 0) {
// temp_2_2 = sceIoctl2(fd, 0x6803, NULL, 0, 0, 0);
// var_17 = ((temp_2_2 < 0) ? 0 : temp_2_2) + 1;
// sceDclose(fd);
// }
// D_004642F4 = 50;
// temp = func_0024A588(&D_0048B4F0, (((u32) (((u32) (arg0 + 0xFFFFF) >> 20) + 0x7F) >> 7) + 1) - var_17);
// if (temp == 0) {
// D_00464354 = -1;
// }
// if (temp_20 != 0) {
// func_0024A3B8();
// }
// D_004642F4 = 80;
// }
D_00464354 = 0;
if (mounted != FALSE) {
func_0024A458();
}
D_004642F4 = 40;
sprintf(filename, "hdd0:%s,,%s", D_00464360.unk_04(), &D_00464330);
fd = sceOpen(filename, SCE_RDONLY);
if (fd >= 0) {
temp = sceIoctl2(fd, HIOCNSUB, NULL, 0, NULL, 0);
if (temp < 0) {
temp = 0;
}
temp++;
sceDclose(fd);
}
D_004642F4 = 50;
val = (((((u32)(arg0 + 0xFFFFF)) >> 20) + 0x7F) >> 7) + 1;
if (func_0024A588("hdd0:", val - temp) == 0) {
D_00464354 = -1;
}
if (mounted != FALSE) {
func_0024A3B8();
}
D_004642F4 = 80;
return D_00464354;
}
s32 func_0024A780(char* dirname, char* arg1) {
struct sce_dirent sp;
@ -159,7 +318,7 @@ s32 func_0024A8B0(void) {
D_004642F4 = 10;
func_0024A458();
if (func_0024A780(D_0048B4F0, D_00464308) != 0) {
if (func_0024A780("hdd0:", D_00464308) != 0) {
cond = TRUE;
D_00464384 = 1;
} else {
@ -203,3 +362,17 @@ s32 func_0024A8B0(void) {
D_004642F4 = 130;
return D_00464358;
}
s32 func_0024AA88() {
return D_00464358;
}
void func_0024AA98(s32 arg0) {
D_00464358 = arg0;
}
// blocked by subsequent 4-byte aligned function breaking split
// s32 func_0024AAA8() {
// return D_0046435C;
// }

View File

@ -1966,6 +1966,7 @@ sceIpuSync = 0x0026efd8; // type:func
sceIpuInit = 0x0026f0a8; // type:func
// hacks for now
func_0024A278 = 0x0024A278; //type:func
D_0048BAB8 = 0x0048BAB8; // type:s32
D_004885C0 = 0x004885C0; // type:s32