mirror of
https://github.com/ethteck/kh1.git
synced 2025-02-18 15:17:37 +00:00
Progress on xkingdom and xapple (#25)
* Adjusted xapple data and rodata splits * Progress on xkingdom * Fixules * some more g00ds * More names * start of xgoblin & some organization * gave the goblin matches * warning cleanup * changes * minor cleanup --------- Co-authored-by: Ethan <ethteck@gmail.com>
This commit is contained in:
parent
40888b079f
commit
8644c4cc1c
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@ -10,9 +10,6 @@
|
||||
"files.associations": {
|
||||
"*.h": "c",
|
||||
},
|
||||
"rust-analyzer.linkedProjects": [
|
||||
"tools/xmaker/Cargo.toml",
|
||||
],
|
||||
"[python]": {
|
||||
"editor.formatOnSave": true,
|
||||
"editor.defaultFormatter": "ms-python.black-formatter",
|
||||
@ -20,4 +17,5 @@
|
||||
"[rust]": {
|
||||
"editor.formatOnSave": true,
|
||||
},
|
||||
"search.useIgnoreFiles": false
|
||||
}
|
||||
|
@ -44,4 +44,6 @@ typedef float f32;
|
||||
f32 cosf(f32);
|
||||
f32 atan2f(f32, f32);
|
||||
|
||||
#define BSS __attribute__ ((section (".bss")))
|
||||
|
||||
#endif /* COMMON_H */
|
||||
|
10
include/common_data.h
Normal file
10
include/common_data.h
Normal file
@ -0,0 +1,10 @@
|
||||
#include "common.h"
|
||||
#include "libvu0.h"
|
||||
|
||||
typedef struct Unk150000 {
|
||||
/* 0x00 */ char unk_00[0x2];
|
||||
/* 0x02 */ s16 unk_02;
|
||||
} Unk150000; // size = ?
|
||||
|
||||
extern sceVu0FMATRIX D_002C1E20;
|
||||
extern u32 D_002C1EA8;
|
5
include/common_funcs.h
Normal file
5
include/common_funcs.h
Normal file
@ -0,0 +1,5 @@
|
||||
#include "common.h"
|
||||
|
||||
void func_0011EDD0(s32*, s32*, s32, s32);
|
||||
void* func_0011ED30(s32, s32 (*func)(void));
|
||||
void func_001208B8();
|
23
include/io.h
23
include/io.h
@ -12,6 +12,27 @@ typedef struct KingdomFile {
|
||||
/* 0x0C */ s32 length;
|
||||
} KingdomFile; // size = 0x10
|
||||
|
||||
KingdomFile* func_0011FFD8(char* filename);
|
||||
typedef struct IOReadTask {
|
||||
/* 0x00 */ u32 flags;
|
||||
/* 0x04 */ char unk_04[0x20];
|
||||
/* 0x24 */ s32 nSector; // kingdom file iso block
|
||||
/* 0x28 */ s32 length; // kingdom file length in bytes
|
||||
/* 0x2C */ void* dst; // data buffer
|
||||
/* 0x30 */ s32 bytesRead; // num read bytes
|
||||
/* 0x34 */ s32 unk_34;
|
||||
} IOReadTask; // size = 0x38
|
||||
|
||||
typedef struct XOtherCrown {
|
||||
/* 0x00 */ s16 unk_00;
|
||||
/* 0x02 */ char unk_02[0xE];
|
||||
/* 0x10 */ char unk_10[0x28];
|
||||
/* 0x38 */ s32 unk_38;
|
||||
/* 0x3C */ s32 unk_3C;
|
||||
/* 0x40 */ s32 unk_40;
|
||||
/* 0x44 */ s32 unk_44;
|
||||
/* 0x48 */ char unk_48[0x4];
|
||||
} XOtherCrown; // size = 0x4C
|
||||
|
||||
KingdomFile* cdvd_FindFile(char* filename);
|
||||
|
||||
#endif /* IO_H */
|
||||
|
@ -239,7 +239,7 @@ extern int *scePowerOffHandler(void (*func)(void *),void *addr);
|
||||
#define SCE_STM_WOTH 00002
|
||||
#define SCE_STM_XOTH 00001
|
||||
|
||||
// #define SCE_STM_ALLUGO \
|
||||
// #define SCE_STM_ALLUGO
|
||||
// (SCE_STM_SUID|SCE_STM_SGID|SCE_STM_SVTX|SCE_STM_RWXUGO)
|
||||
#define SCE_STM_RWXUGO (SCE_STM_RWXU|SCE_STM_RWXG|SCE_STM_RWXO)
|
||||
#define SCE_STM_RUGO (SCE_STM_RUSR|SCE_STM_RGRP|SCE_STM_ROTH)
|
||||
|
21
kh.jp.yaml
21
kh.jp.yaml
@ -40,10 +40,11 @@ segments:
|
||||
- [0x11120, c, xtrumpet]
|
||||
- [0x11FC0, c, xspinach]
|
||||
- [0x121E8, asm]
|
||||
- [0x1FCD8, c, xkingdom]
|
||||
- [0x207F8, asm]
|
||||
- [0x1EC48, c, xgoblin]
|
||||
- [0x1FBE8, c, xkingdom]
|
||||
- [0x20AB8, asm]
|
||||
- [0x3ABE8, c, xapple]
|
||||
- [0x3BD28, asm]
|
||||
- [0x3BE08, asm]
|
||||
- [0x49D68, c, xsquash]
|
||||
- [0x4A098, asm]
|
||||
####################
|
||||
@ -475,6 +476,8 @@ segments:
|
||||
- [0x16F0C0, asm, libipu/ipuinit]
|
||||
|
||||
- [0x16F360, data]
|
||||
- [0x201090, .data, xapple]
|
||||
- [0x2010F8, data] # todo: xapple owns D_00301078
|
||||
- [0x2DE638, data, xquack]
|
||||
- [0x2DE670, data]
|
||||
- [0x364368, .data, disk]
|
||||
@ -488,7 +491,7 @@ segments:
|
||||
- [0x364BA8, data, libkernl/alarm]
|
||||
- [0x365350, data, libkernl/kprintf]
|
||||
- [0x365358, data, libkernl/sifrpc]
|
||||
- [0x365360, data, libkernl/filestub]
|
||||
- [0x365360, .data, lib/libkernl/filestub]
|
||||
# - [0x3653F4, data, libkernl/eeloadfile]
|
||||
- [0x365400, data, libkernl/initsys]
|
||||
- [0x365418, data, libkernl/libosd]
|
||||
@ -516,10 +519,10 @@ segments:
|
||||
- [0x386DB0, .rodata, xspinach]
|
||||
- [0x386DB8, rodata, 121E8]
|
||||
- [0x386FF0, .rodata, xkingdom]
|
||||
- [0x387048, rodata, 207F8]
|
||||
- [0x387A50, rodata, xapple]
|
||||
- [0x387A58, rodata, blob3]
|
||||
- [0x387A60, rodata, 3BD28]
|
||||
- [0x387080, rodata, 20AB8]
|
||||
- [0x3879E8, .rodata, xapple]
|
||||
- [0x387A58, rodata, blob3] # todo: part of xapple
|
||||
- [0x387A60, rodata, 3BE08]
|
||||
- [0x3881C0, rodata, 4A098]
|
||||
- [0x389BC0, rodata, DF218]
|
||||
- [0x38A700, .rodata, xmeowp]
|
||||
@ -542,7 +545,7 @@ segments:
|
||||
- [0x38BB80, rodata, libc/mprec]
|
||||
- [0x38BCA8, rodata, libkernl/tty]
|
||||
- [0x38BD20, rodata, libkernl/kprintf]
|
||||
- [0x38BE80, rodata, libkernl/filestub]
|
||||
- [0x38BE80, .rodata, lib/libkernl/filestub]
|
||||
- [0x38BEF8, rodata, libkernl/eeloadfile]
|
||||
- [0x38BF00, rodata, libkernl/iopreset]
|
||||
- [0x38BF30, rodata, libkernl/thread]
|
||||
|
@ -291,7 +291,7 @@ s32 disk_SetBlock(s32* isoBlock) {
|
||||
*isoBlock = 0;
|
||||
}
|
||||
|
||||
kingdomFile = func_0011FFD8("kingdom.img");
|
||||
kingdomFile = cdvd_FindFile("kingdom.img");
|
||||
if (kingdomFile != NULL) {
|
||||
length = kingdomFile->length;
|
||||
if (isoBlock != NULL) {
|
||||
|
@ -2,11 +2,15 @@
|
||||
#include "eekernel.h"
|
||||
#include <sifdev.h>
|
||||
|
||||
s32 _fs_init;
|
||||
s32 _fs_semid;
|
||||
s32 _fs_iob_semid;
|
||||
s32 _fs_fsq_semid;
|
||||
s32 D_004652E0[32] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
|
||||
};
|
||||
s32 _fs_init = 0;
|
||||
s32 _fs_semid = -1;
|
||||
s32 _fs_iob_semid = -1;
|
||||
s32 _fs_fsq_semid = -1;
|
||||
|
||||
// BSS
|
||||
char _fsversion[24];
|
||||
|
||||
void _sceFsIobSemaMK() {
|
||||
@ -54,7 +58,22 @@ INCLUDE_ASM(const s32, "lib/libkernl/filestub", _sceFs_Poff_Intr);
|
||||
|
||||
INCLUDE_ASM(const s32, "lib/libkernl/filestub", sceFsInit);
|
||||
|
||||
INCLUDE_ASM(const s32, "lib/libkernl/filestub", _fs_version);
|
||||
char* D_00465370 = "....";
|
||||
s32 D_00465374 = -1;
|
||||
char* D_00465378 = "....\0"; // TODO remove \0 or move this string to another file. the compiler is de-duplicating it.
|
||||
|
||||
extern char* D_00464B18;
|
||||
|
||||
s32 _fs_version(void) {
|
||||
s32 ret = FALSE;
|
||||
|
||||
if (D_00464B18) {} // TODO fake match
|
||||
|
||||
if (memcmp(&_fsversion, &D_00464B18, 4) != 0 && memcmp(&_fsversion, D_00465370, 4) != 0) {
|
||||
ret = memcmp(&D_00464B18, D_00465370, 4) != 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Invalidate file service bind information.
|
||||
|
221
src/xapple.c
221
src/xapple.c
@ -1,7 +1,7 @@
|
||||
#include "common.h"
|
||||
#include "common_funcs.h"
|
||||
|
||||
#include "gcc/stdio.h"
|
||||
|
||||
#include "eekernel.h"
|
||||
#include "libvu0.h"
|
||||
|
||||
@ -12,9 +12,19 @@ typedef struct XAppleStemTip {
|
||||
|
||||
typedef struct XAppleStem {
|
||||
/* 0x00 */ s32 unk_00[0x6C / 4];
|
||||
/* 0x6C */ XAppleStemTip *unk_6C;
|
||||
/* 0x6C */ XAppleStemTip* unk_6C;
|
||||
} XAppleStem;
|
||||
|
||||
typedef struct AppleWormInner {
|
||||
/* 0x00 */ u8 unk_00;
|
||||
/* 0x01 */ char unk_01[0x7];
|
||||
} AppleWormInner;
|
||||
|
||||
typedef struct AppleWorm {
|
||||
/* 0x00 */ char unk_00[0x98];
|
||||
/* 0x98 */ AppleWormInner unk_98[2];
|
||||
} AppleWorm;
|
||||
|
||||
typedef struct XApple4 {
|
||||
/* 0x00 */ s32 unk_00[4];
|
||||
} XApple4;
|
||||
@ -41,8 +51,30 @@ typedef struct XAppleBlemish {
|
||||
/* 0x444 */ s32 unk_444;
|
||||
} XAppleBlemish;
|
||||
|
||||
typedef struct LargeApple {
|
||||
/* 0x00 */ char unk_00[0x30];
|
||||
/* 0x30 */ f32 unk_30[3];
|
||||
/* 0x3C */ f32 unk_3C;
|
||||
} LargeApple;
|
||||
|
||||
typedef struct OtherApple {
|
||||
/* 0x00 */ u16 unk_00;
|
||||
/* 0x02 */ char unk_02[0xE];
|
||||
/* 0x10 */ f32 unk_10;
|
||||
} OtherApple;
|
||||
|
||||
typedef struct AppleCore {
|
||||
/* 0x00 */ f32 unk_00;
|
||||
/* 0x04 */ s32 (*unk_04)();
|
||||
} AppleCore;
|
||||
|
||||
s32 func_001009A8();
|
||||
void* func_00122AF8(s32, s32, s32);
|
||||
s32 func_00122B70(void*);
|
||||
extern f32 D_002B8340[];
|
||||
extern LargeApple* D_00532504;
|
||||
|
||||
// funcs
|
||||
s32 func_0011ED30(s32, s32 (*func)(void));
|
||||
s32 func_0011EF58(s32*, s32);
|
||||
s32 func_00120590(char*, void*, void*, void*);
|
||||
f32 func_00120A38(sceVu0FVECTOR);
|
||||
@ -60,10 +92,17 @@ s32 func_00132160(s32, s32, s32);
|
||||
void func_001372F8(f32, XAppleBlemish*);
|
||||
void func_00137348(XAppleBlemish*);
|
||||
void func_0013A790(void);
|
||||
s32 func_0013AFE8(void);
|
||||
s32 func_0013B368(void);
|
||||
s32 func_0013B6E0(void);
|
||||
s32 func_0013B890(void);
|
||||
s32 func_0013B1D0(void);
|
||||
void func_0013B578(void);
|
||||
s32 func_0013BD88(s32*, s32*, s32);
|
||||
s32 func_0013BD88(s32*, AppleCore*, s32);
|
||||
s32 func_0013BDA0(s32*);
|
||||
s32 func_00141668(XAppleBlemish*, s32);
|
||||
XApple4* func_00155ED8(s32, s32);
|
||||
void func_00157AD8(s32);
|
||||
s32 func_00157B90(void);
|
||||
void func_00163638(sceVu0FMATRIX, sceVu0FMATRIX);
|
||||
void func_00177828(s32);
|
||||
@ -86,17 +125,31 @@ extern XAppleStem* D_002DEC00;
|
||||
extern sceVu0FVECTOR D_002DECE0;
|
||||
extern sceVu0FVECTOR D_002DECF0;
|
||||
extern u32 D_002DED20;
|
||||
extern sceVu0FVECTOR D_00301030;
|
||||
extern sceVu0FVECTOR D_00301040;
|
||||
|
||||
char* D_00301010[8] = {
|
||||
"xs_dumbo", "xs_bambi", "xs_genie", "xs_tink", "xs_mushu", "xs_simba",
|
||||
};
|
||||
sceVu0FVECTOR D_00301030 = {0.0f, -120.0f, -70.0f, 1.0f};
|
||||
sceVu0FVECTOR D_00301040 = {0.0f, -100.0f, -20.0f, 1.0f};
|
||||
char* D_00301050 = ".dbt";
|
||||
char* D_00301054 = ".x";
|
||||
AppleCore D_00301058[4] = {
|
||||
{60.0f, func_0013AFE8},
|
||||
{30.0f, func_0013B368},
|
||||
{60.0f, func_0013B6E0},
|
||||
{0.0f, func_0013B890},
|
||||
};
|
||||
char* D_00301078; // = ".dat";
|
||||
|
||||
extern s32 D_00301080;
|
||||
extern s32 D_00301088;
|
||||
extern s32 D_00301010[];
|
||||
extern s32 D_00301050;
|
||||
extern s32 D_00301054;
|
||||
extern s32 D_00301058;
|
||||
extern f32 D_0030108C;
|
||||
extern f32 D_00301090;
|
||||
extern s32 D_00301094;
|
||||
extern AppleWorm* D_003051EC;
|
||||
extern u32 D_00375BC0;
|
||||
|
||||
// .rodata
|
||||
extern char D_004879D0[]; // "%s%s"
|
||||
|
||||
// .bss ?
|
||||
extern f32 D_005324B4;
|
||||
@ -109,6 +162,7 @@ extern sceVu0FVECTOR D_005324F0;
|
||||
extern f32 D_00532500;
|
||||
extern s32 D_00532508;
|
||||
extern s32 D_00532518;
|
||||
extern s32 D_00532528;
|
||||
extern XAppleBlemish* D_005325E8;
|
||||
extern XAppleBlemish* D_005325EC;
|
||||
extern sceVu0FVECTOR D_005325F0;
|
||||
@ -248,7 +302,8 @@ INCLUDE_ASM(const s32, "xapple", func_0013B1D0);
|
||||
// D_002C1EA8 |= 0x4000;
|
||||
// if (((s32)((D_002C1EC8 >> 8) % 4) < 2) && (D_00532608[1].unk_00[1] != D_00532608[1].unk_00[0])) {
|
||||
// func_001313A8(D_005325E8, (s32)D_00532608 + D_00532608->unk_00[3]);
|
||||
// func_001C64E0((s32)D_00532608 + D_00532608[1].unk_00[0], (s32)D_00532608 + D_00532608[1].unk_00[1], (s32)D_00532608 + D_00532608[1].unk_00[2]);
|
||||
// func_001C64E0((s32)D_00532608 + D_00532608[1].unk_00[0], (s32)D_00532608 + D_00532608[1].unk_00[1],
|
||||
// (s32)D_00532608 + D_00532608[1].unk_00[2]);
|
||||
// }
|
||||
// return 4;
|
||||
// }
|
||||
@ -261,40 +316,18 @@ s32 func_0013B368(void) {
|
||||
}
|
||||
func_00157B90();
|
||||
D_00532604 = 3;
|
||||
sprintf(something, D_004879D0, D_00301010[D_00532600], D_00301050);
|
||||
sprintf(something, "%s%s", D_00301010[D_00532600], D_00301050);
|
||||
func_00120590(something, D_0053260C, NULL, 0);
|
||||
sprintf(something, D_004879D0, D_00301010[D_00532600], D_00301054);
|
||||
sprintf(something, "%s%s", D_00301010[D_00532600], D_00301054);
|
||||
func_00120590(something, &func_F20000, &func_0013B138, 0);
|
||||
func_0011ED30(47000, &func_0013B1D0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
INCLUDE_ASM(const s32, "xapple", func_0013B480);
|
||||
|
||||
// typedef struct LargeApple {
|
||||
// /* 0x00 */ char unk_00[0x30];
|
||||
// /* 0x30 */ f32 unk_30[3];
|
||||
// /* 0x3C */ f32 unk_3C;
|
||||
// } LargeApple;
|
||||
|
||||
// typedef struct OtherApple {
|
||||
// /* 0x00 */ u16 unk_00;
|
||||
// /* 0x02 */ char unk_02[0xE];
|
||||
// /* 0x10 */ f32 unk_10;
|
||||
// } OtherApple;
|
||||
|
||||
// s32 func_001009A8();
|
||||
// void* func_00122AF8(s32, s32, s32);
|
||||
// s32 func_00122B70(void*);
|
||||
// extern f32 D_002B8340[];
|
||||
// extern LargeApple* D_00532504;
|
||||
|
||||
// s32 func_0013B480(OtherApple* arg0) {
|
||||
// f32 temp_f2;
|
||||
|
||||
// if (arg0->unk_00 & 0x10) {
|
||||
// LargeApple* a;
|
||||
|
||||
// D_00532504 = func_00122AF8(1, 9, 0);
|
||||
// D_00532504->unk_30[0] = D_00532504->unk_30[1] = D_00532504->unk_30[2] = 0.0f;
|
||||
// D_00532504->unk_3C = 1.0f;
|
||||
@ -302,7 +335,6 @@ INCLUDE_ASM(const s32, "xapple", func_0013B480);
|
||||
// arg0->unk_10 = 60.0f;
|
||||
// }
|
||||
// arg0->unk_10 -= D_002B8340[1];
|
||||
|
||||
// temp_f2 = arg0->unk_10 / 60.0f;
|
||||
// if (arg0->unk_10 / 60.0f <= 0.0f) {
|
||||
// func_00122B70(D_00532504);
|
||||
@ -332,7 +364,8 @@ INCLUDE_ASM(const s32, "xapple", func_0013B578);
|
||||
// var_16 = func_001234A0(NULL);
|
||||
// if (var_16 != NULL) {
|
||||
// do {
|
||||
// if (!((var_16->unk_370 >> 0x21) & 1) && (var_16 != D_002DEC00->unk_00[1]) && (var_16 != D_002DEC00->unk_00[2])) {
|
||||
// if (!((var_16->unk_370 >> 0x21) & 1) && (var_16 != D_002DEC00->unk_00[1]) && (var_16 !=
|
||||
// D_002DEC00->unk_00[2])) {
|
||||
// func_00123858(var_16);
|
||||
// }
|
||||
// var_16 = func_001234A0(var_16);
|
||||
@ -383,7 +416,7 @@ INCLUDE_ASM(const s32, "xapple", func_0013B6E0);
|
||||
// }
|
||||
// D_005325EC->unk_444 = 0;
|
||||
// }
|
||||
// if ((((u32) D_002C1EC8 >> 8) % 4) != 1) {
|
||||
// if ((((u32)D_002C1EC8 >> 8) % 4) != 1) {
|
||||
// if (D_0053260C[3] - D_0053260C[2] > 0) {
|
||||
// func_001313A8(D_005325E8, (s32)D_0053260C + D_0053260C[2]);
|
||||
// func_00130248(D_005325E8, 0.0f, 0);
|
||||
@ -409,7 +442,7 @@ s32 func_0013B890(void) {
|
||||
|
||||
s32 func_0013B8F8(u16* arg0) {
|
||||
if (*arg0 & 0x10) {
|
||||
func_0013BD88(&D_00532508, &D_00301058, 4);
|
||||
func_0013BD88(&D_00532508, D_00301058, 4);
|
||||
}
|
||||
func_0011EF58(&D_00532518, 0);
|
||||
return (func_0013BDA0(&D_00532508) != 0) ? 0 : 4;
|
||||
@ -422,63 +455,75 @@ void func_0013B968(s32 arg0) {
|
||||
((D_00532608->unk_00[3] - D_00532608->unk_00[2]) <= 0) ? 0 : ((s32)D_00532608->unk_00 + D_00532608->unk_00[2])
|
||||
);
|
||||
}
|
||||
|
||||
void func_0013B9A8(void) {
|
||||
D_00532604 = 2;
|
||||
}
|
||||
|
||||
INCLUDE_ASM(const s32, "xapple", func_0013B9B8);
|
||||
s32 func_0013B9B8();
|
||||
// s32 func_0013B9B8(s32 arg0, s32 arg1, s32 arg2) {
|
||||
// int iVar1;
|
||||
// int iVar2;
|
||||
|
||||
// iVar2 = *(int*)(arg2 + 8);
|
||||
// if (iVar2 - *(int*)(arg2 + 4) < 1) {
|
||||
// iVar1 = *(int*)(arg2 + 0xc);
|
||||
// } else {
|
||||
// func_00156058(arg2 + *(int*)(arg2 + 4));
|
||||
// iVar2 = *(int*)(arg2 + 8);
|
||||
// iVar1 = *(int*)(arg2 + 0xc);
|
||||
// }
|
||||
// if (iVar1 - iVar2 < 1) {
|
||||
// iVar2 = *(int*)(arg2 + 0x10);
|
||||
// } else {
|
||||
// func_001560C8(arg2 + iVar2);
|
||||
// iVar1 = *(int*)(arg2 + 0xc);
|
||||
// iVar2 = *(int*)(arg2 + 0x10);
|
||||
// }
|
||||
// if (iVar2 - iVar1 < 1) {
|
||||
// iVar2 = *(int*)(arg2 + 0x18);
|
||||
// } else {
|
||||
// func_001560C8(arg2 + iVar1);
|
||||
// iVar2 = *(int*)(arg2 + 0x18);
|
||||
// }
|
||||
// if (0 < iVar2 - *(int*)(arg2 + 0x14)) {
|
||||
// func_00177908(arg2 + *(int*)(arg2 + 0x14));
|
||||
// }
|
||||
// D_00532604 = 1;
|
||||
// if (*(int*)(arg2 + 0x20) - *(int*)(arg2 + 0x1c) < 1) {
|
||||
// D_00532604 = 2;
|
||||
// } else {
|
||||
// func_00146BC8(-7);
|
||||
// func_00146D08(arg2 + *(int*)(arg2 + 0x1c), -7, func_0013B9A8, 0);
|
||||
// }
|
||||
// D_0053260C = (s32*)(arg2 + arg0 + 0x7fU & 0xffffff80);
|
||||
// }
|
||||
|
||||
f32 func_0013BAC0(void) {
|
||||
return (D_002DEC00->unk_6C->unk_48 + ((s32)(D_002DED20 >> 0xA) & 7)) * 3000;
|
||||
}
|
||||
|
||||
// s32 func_0011EDD0(s32*, s32*, s32, s32);
|
||||
// s32 func_00141668(XAppleBlemish*, s32);
|
||||
// XApple4* func_00155ED8(s32, s32);
|
||||
// void func_00157AD8(s32);
|
||||
void* func_0013BB00(s32 arg0, s32 arg1) {
|
||||
char something[0x20];
|
||||
|
||||
// typedef struct AppleWormInner {
|
||||
// /* 0x00 */ u8 unk_00;
|
||||
// /* 0x01 */ char unk_01[0x7];
|
||||
// } AppleWormInner;
|
||||
D_002C1EA8 |= 0x102000;
|
||||
D_00301088 = (D_00301088 & (~7)) | (arg1 & 7) | 8;
|
||||
D_00301080 = &D_003051EC->unk_98[arg1].unk_00;
|
||||
D_00301094 |= 1 << arg1;
|
||||
D_0030108C = D_00301090 = func_0013BAC0();
|
||||
func_00141668(arg0, -*(&D_003051EC->unk_98[arg1].unk_00));
|
||||
D_005325E8 = arg0;
|
||||
D_00532600 = arg1;
|
||||
func_00157AD8(1);
|
||||
func_00157AD8(2);
|
||||
func_00157AD8(3);
|
||||
D_00532604 = 0;
|
||||
D_00532608 = func_00155ED8(0x34, 0xC);
|
||||
sprintf(something, "%s%s", D_00301010[arg1], D_00301078);
|
||||
func_00120590(something, D_00532608, func_0013B9B8, 0);
|
||||
func_0011EDD0(&D_00532518, &D_00532528, 0x18, 8);
|
||||
return func_0011ED30(52000, func_0013B8F8);
|
||||
}
|
||||
|
||||
// typedef struct AppleWorm {
|
||||
// /* 0x00 */ char unk_00[0x98];
|
||||
// /* 0x98 */ AppleWormInner unk_98[2];
|
||||
// } AppleWorm;
|
||||
|
||||
// extern s32 D_00301078;
|
||||
// extern s32 D_00301080;
|
||||
// extern f32 D_0030108C;
|
||||
// extern f32 D_00301090;
|
||||
// extern s32 D_00301094;
|
||||
// extern AppleWorm* D_003051EC;
|
||||
|
||||
// extern s32 D_00532528;
|
||||
|
||||
// extern s32 func_0013B9B8;
|
||||
|
||||
// void func_0013BB00(s32 arg0, s32 arg1) {
|
||||
// char something[0x30];
|
||||
|
||||
// D_002C1EA8 |= 0x102000;
|
||||
// D_00301080 = &D_003051EC.unk_98[arg1].unk_00;
|
||||
// D_00301088 = (D_00301088 & ~7) | (arg1 & 7) | 8;
|
||||
// D_00301094 |= 1 << arg1;
|
||||
// D_0030108C = func_0013BAC0();
|
||||
// D_00301090 = D_0030108C;
|
||||
// func_00141668(arg0, -D_003051EC.unk_98[arg1].unk_00);
|
||||
// D_005325E8 = arg0;
|
||||
// D_00532600 = arg1;
|
||||
// func_00157AD8(1);
|
||||
// func_00157AD8(2);
|
||||
// func_00157AD8(3);
|
||||
// D_00532604 = 0;
|
||||
// D_00532608 = func_00155ED8(0x34, 0xC);
|
||||
// sprintf(something, &D_004879D0, D_00301010[arg1], D_00301078);
|
||||
// func_00120590(something, D_00532608, &func_0013B9B8, 0);
|
||||
// func_0011EDD0(&D_00532518, &D_00532528, 0x18, 8);
|
||||
// func_0011ED30(52000, &func_0013B8F8);
|
||||
// }
|
||||
|
||||
INCLUDE_ASM(const s32, "xapple", func_0013BB00);
|
||||
INCLUDE_ASM(const s32, "xapple", func_0013BCA8);
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include "common_funcs.h"
|
||||
|
||||
#include "disk.h"
|
||||
#include "io.h"
|
||||
#include "libgraph.h"
|
||||
@ -37,7 +39,6 @@ extern s32 D_0048EC08;
|
||||
extern void func_F20000(s32, s32);
|
||||
extern void func_00100240(); // in xbeginning
|
||||
extern void func_00110230(s32);
|
||||
extern void func_0011EDD0(s32*, s32*, s32, s32);
|
||||
extern u_long128* func_00121C98(s32, u_long128**);
|
||||
extern void func_00122518();
|
||||
extern s32* func_00155ED8(s32, s32);
|
||||
@ -56,7 +57,7 @@ void func_001090D8() {
|
||||
func_0022F578(-1);
|
||||
func_0011EAF8(D_002B29B0, D_004869E0);
|
||||
|
||||
file = func_0011FFD8(D_004869F8);
|
||||
file = cdvd_FindFile(D_004869F8);
|
||||
if (file != NULL) {
|
||||
disk_Mgr.unk_18(file->length);
|
||||
} else {
|
||||
@ -76,13 +77,13 @@ s32 func_001091B0() {
|
||||
|
||||
INCLUDE_ASM(const s32, "xarcade", func_001091D8);
|
||||
|
||||
s32 func_00109340() {
|
||||
void* func_00109340() {
|
||||
func_00110190();
|
||||
func_00176E30();
|
||||
func_00176E98();
|
||||
D_00358BE0 = 1;
|
||||
func_0011EDD0(&D_002B8C70, &D_002B8870, 0x20, 0x20);
|
||||
return func_0011ED30(0x2E662, func_001091B0);
|
||||
return func_0011ED30(190050, func_001091B0);
|
||||
}
|
||||
|
||||
INCLUDE_ASM(const s32, "xarcade", func_001093A8);
|
||||
@ -115,18 +116,18 @@ s32 func_00109AA0() {
|
||||
sceGsSetDefStoreImage(&img, 0x1A00, 8, 1, 0, 0, 0x200, 0x180);
|
||||
FlushCache(WRITEBACK_DCACHE);
|
||||
sceGsSyncPath(0, 0);
|
||||
sceGsExecStoreImage(&img, func_F20000);
|
||||
sceGsExecStoreImage(&img, func_F20000); // TODO look into - F20000 is probably an overlay location
|
||||
return 4;
|
||||
}
|
||||
|
||||
s32 func_00109B00() {
|
||||
void* func_00109B00() {
|
||||
return func_0011ED30(190000, func_00109AA0);
|
||||
}
|
||||
|
||||
INCLUDE_ASM(const s32, "xarcade", func_00109B28);
|
||||
void func_00109B28();
|
||||
s32 func_00109B28();
|
||||
|
||||
s32 func_00109C50(s32 arg0) {
|
||||
void* func_00109C50(s32 arg0) {
|
||||
D_0048EC00.unk_04 = arg0 << 1;
|
||||
D_0048EC08 = 0;
|
||||
return func_0011ED30(190000, func_00109B28);
|
||||
@ -145,7 +146,7 @@ s32 func_00109D68() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
s32 func_00109DE8() {
|
||||
void* func_00109DE8() {
|
||||
D_002B2CC4 = 1;
|
||||
if (D_002B85C0[0] != 0x80) {
|
||||
func_001037C8(1);
|
||||
@ -154,12 +155,12 @@ s32 func_00109DE8() {
|
||||
}
|
||||
|
||||
INCLUDE_ASM(const s32, "xarcade", func_00109E30);
|
||||
void func_00109E30();
|
||||
s32 func_00109E30();
|
||||
|
||||
INCLUDE_ASM(const s32, "xarcade", func_00109F60);
|
||||
s32 func_00109F60();
|
||||
|
||||
s32 func_0010A040() {
|
||||
void* func_0010A040() {
|
||||
D_0048EC00.unk_00 = 0;
|
||||
if (D_002B2CC0 != 0) {
|
||||
return func_0011ED30(190000, func_00109F60);
|
||||
|
218
src/xgoblin.c
Normal file
218
src/xgoblin.c
Normal file
@ -0,0 +1,218 @@
|
||||
#include "common.h"
|
||||
#include "common_funcs.h"
|
||||
#include "common_data.h"
|
||||
|
||||
#include "io.h"
|
||||
|
||||
#include "libpc.h"
|
||||
#include "libpad2.h"
|
||||
#include "libvu0.h"
|
||||
|
||||
typedef struct XGoblin {
|
||||
/* 0x00 */ u16 unk_00;
|
||||
/* 0x02 */ u16 unk_02;
|
||||
/* 0x04 */ s32 unk_04;
|
||||
/* 0x08 */ struct XGoblin* unk_08;
|
||||
/* 0x0C */ u32 (*unk_0C)(struct XGoblin*);
|
||||
} XGoblin;
|
||||
|
||||
void func_0011F938();
|
||||
void func_00121AE8();
|
||||
void func_00122110();
|
||||
void func_00122410();
|
||||
void func_0012FB18();
|
||||
void func_00147870();
|
||||
|
||||
extern f32 D_002B8340[];
|
||||
extern sceVu0FMATRIX D_002C1E60;
|
||||
extern s32 D_002C1EA0;
|
||||
extern s32 D_002C1EBC;
|
||||
extern f32 D_002C1EC0;
|
||||
extern u32 D_002C1EE0[30][2];
|
||||
extern scePad2SocketParam D_002C1FD8;
|
||||
|
||||
extern UNK_TYPE D_004DD188;
|
||||
extern UNK_TYPE D_004DD198[];
|
||||
extern u_long128 D_004DDA00;
|
||||
extern s32 D_004DDC00;
|
||||
|
||||
s32 func_0011EBC8(void) {
|
||||
func_00122250();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void func_0011EBE8(void) {
|
||||
s32 i, j;
|
||||
|
||||
sceVu0UnitMatrix(D_002C1E20);
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(D_002C1E60); i++) {
|
||||
for (j = 0; j < ARRAY_COUNT(D_002C1E60[0]); j++) {
|
||||
D_002C1E60[i][j] = 0;
|
||||
}
|
||||
}
|
||||
D_002C1EA0 = 0;
|
||||
D_002C1EA8 = 0;
|
||||
D_002C1EBC = 0;
|
||||
func_0011EDD0(&D_004DD188, D_004DD198, 0x10, 0x80);
|
||||
func_00122110();
|
||||
func_00121AE8();
|
||||
func_00122410();
|
||||
func_001208B8();
|
||||
func_00147870();
|
||||
func_0011F938();
|
||||
func_0012FB18();
|
||||
((XGoblin*)func_0011ED30(150000, func_0011EBC8))->unk_02 = -1;
|
||||
}
|
||||
|
||||
void func_0011ECD0(void) {
|
||||
D_002C1EC0 = 1.0f / D_002B8340[1];
|
||||
func_0011EF58(&D_004DD188, D_002C1EBC);
|
||||
D_002C1EA0 ^= 1;
|
||||
}
|
||||
|
||||
INCLUDE_ASM(const s32, "xgoblin", func_0011ED30);
|
||||
|
||||
void func_0011ED60(s32 arg0) {
|
||||
func_0011F108(&D_004DD188, arg0);
|
||||
}
|
||||
|
||||
s32 func_0011ED80(s32 arg0) {
|
||||
s32 val = func_0011F108(&D_004DD188, arg0);
|
||||
if (val != 0) {
|
||||
return func_0011F148(&D_004DD188, val);
|
||||
}
|
||||
}
|
||||
|
||||
INCLUDE_ASM(const s32, "xgoblin", func_0011EDD0);
|
||||
|
||||
INCLUDE_ASM(const s32, "xgoblin", func_0011EE10);
|
||||
|
||||
XGoblin* func_0011EE80(XGoblin* arg0, XGoblin* arg1) {
|
||||
XGoblin* pXVar;
|
||||
XGoblin* pXVar2 = NULL;
|
||||
|
||||
for (pXVar = arg0->unk_08; pXVar != NULL && pXVar != arg1; pXVar = pXVar->unk_08) {
|
||||
pXVar2 = pXVar;
|
||||
}
|
||||
|
||||
return pXVar2;
|
||||
}
|
||||
|
||||
INCLUDE_ASM(const s32, "xgoblin", func_0011EEB8);
|
||||
|
||||
s32 func_0011EF58(XGoblin* arg0, s32 arg1) {
|
||||
u32 uVar3;
|
||||
|
||||
s32 sVar5 = 0;
|
||||
XGoblin* pXVar2 = NULL;
|
||||
XGoblin* next = arg0->unk_08;
|
||||
|
||||
while (next != 0) {
|
||||
if ((next->unk_02 & arg1) == arg1) {
|
||||
uVar3 = next->unk_0C(next);
|
||||
next->unk_00 &= 0xFFEF;
|
||||
|
||||
if (uVar3 & 4) {
|
||||
if (pXVar2 != 0) {
|
||||
if (pXVar2->unk_08 != next) {
|
||||
pXVar2 = func_0011EE80(arg0, next);
|
||||
}
|
||||
pXVar2->unk_08 = next->unk_08;
|
||||
} else {
|
||||
arg0->unk_08 = next->unk_08;
|
||||
}
|
||||
next->unk_00 = 0;
|
||||
} else {
|
||||
pXVar2 = next;
|
||||
}
|
||||
|
||||
sVar5++;
|
||||
|
||||
if (uVar3 & 8) {
|
||||
pXVar2 = next;
|
||||
break;
|
||||
}
|
||||
}
|
||||
next = next->unk_08;
|
||||
}
|
||||
|
||||
arg0->unk_0C = NULL;
|
||||
return sVar5;
|
||||
}
|
||||
|
||||
s32 func_0011F050(XGoblin* arg0, u16 (*arg1)(XGoblin*)) {
|
||||
XGoblin* next;
|
||||
XGoblin* gob;
|
||||
|
||||
s32 iVar1 = 0;
|
||||
|
||||
for (next = arg0->unk_08; next != NULL; next = next->unk_08) {
|
||||
if (((next->unk_00 | arg1(next)) & 4) != 0) {
|
||||
gob = func_0011EE80(arg0, next);
|
||||
if (gob != NULL) {
|
||||
gob->unk_08 = next->unk_08;
|
||||
} else {
|
||||
arg0->unk_08 = next->unk_08;
|
||||
}
|
||||
next->unk_00 = 0;
|
||||
}
|
||||
iVar1++;
|
||||
}
|
||||
|
||||
return iVar1;
|
||||
}
|
||||
|
||||
b32 func_0011F0F8(XOtherCrown* arg0) {
|
||||
return arg0->unk_00 & 1;
|
||||
}
|
||||
|
||||
INCLUDE_ASM(const s32, "xgoblin", func_0011F108);
|
||||
|
||||
INCLUDE_ASM(const s32, "xgoblin", func_0011F148);
|
||||
|
||||
INCLUDE_ASM(const s32, "xgoblin", func_0011F1A0);
|
||||
|
||||
INCLUDE_ASM(const s32, "xgoblin", func_0011F388);
|
||||
|
||||
u32 func_0011F478(u32 arg0) {
|
||||
u32 i;
|
||||
u32 uVar3 = 0;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(D_002C1EE0); i++) {
|
||||
if ((arg0 & D_002C1EE0[i][0]) == D_002C1EE0[i][0]) {
|
||||
uVar3 |= D_002C1EE0[i][1];
|
||||
}
|
||||
}
|
||||
|
||||
return uVar3;
|
||||
}
|
||||
|
||||
INCLUDE_ASM(const s32, "xgoblin", func_0011F4B8);
|
||||
|
||||
INCLUDE_ASM(const s32, "xgoblin", func_0011F7C0);
|
||||
|
||||
INCLUDE_ASM(const s32, "xgoblin", func_0011F8C0);
|
||||
// void func_0011F8C0() {
|
||||
// sceDbcInit();
|
||||
// scePad2Init(0);
|
||||
// D_004DDC00 = scePad2CreateSocket(&D_002C1FD8, &D_004DDA00);
|
||||
// }
|
||||
|
||||
s32 func_0011F908() {
|
||||
scePcStart(0x8000F8DE, 0, 0); // TODO: libpc bitfield macro combination
|
||||
return 0;
|
||||
}
|
||||
|
||||
void func_0011F938() {
|
||||
func_0011F908();
|
||||
((XGoblin*)func_0011ED30(10000, func_0011F908))->unk_02 = -1;
|
||||
}
|
||||
|
||||
INCLUDE_ASM(const s32, "xgoblin", func_0011F970);
|
||||
|
||||
INCLUDE_ASM(const s32, "xgoblin", func_0011F980);
|
||||
|
||||
INCLUDE_ASM(const s32, "xgoblin", func_0011F9B0);
|
||||
|
||||
INCLUDE_ASM(const s32, "xgoblin", func_0011F9E8);
|
@ -1,3 +1,5 @@
|
||||
#include "common_data.h"
|
||||
|
||||
#include "xhumungus.h"
|
||||
#include "xflamingo.h"
|
||||
|
||||
@ -21,7 +23,6 @@ extern u32 D_002B9660;
|
||||
extern s32 D_002C2104;
|
||||
extern s32 D_002C2108;
|
||||
extern s32 D_002C2024;
|
||||
extern u32 D_002C1EA8;
|
||||
extern u16 D_002C1EAA;
|
||||
extern u32 D_002DED08;
|
||||
extern u32 D_00375BC0;
|
||||
@ -1908,7 +1909,7 @@ void func_001DB5D0(); // temp for next function
|
||||
INCLUDE_ASM(const s32, "xhumungus", func_001DB5D0);
|
||||
|
||||
s32 func_001DB618() {
|
||||
func_0011ED30(0xC352, func_001DB5D0);
|
||||
func_0011ED30(50002, func_001DB5D0);
|
||||
D_003854E0.unk_3078 |= 4;
|
||||
return 2;
|
||||
}
|
||||
|
318
src/xkingdom.c
318
src/xkingdom.c
@ -5,29 +5,19 @@
|
||||
#include "sdk/ee/eekernel.h"
|
||||
#include "sdk/ee/sifdev.h"
|
||||
|
||||
#include "gcc/stdlib.h"
|
||||
#include "gcc/string.h"
|
||||
|
||||
typedef struct XCrown {
|
||||
/* 0x00 */ u32 flags;
|
||||
/* 0x04 */ char unk_04[0x20];
|
||||
/* 0x24 */ s32 nSector; // kingdom file iso block
|
||||
/* 0x28 */ s32 length; // kingdom file length in bytes
|
||||
/* 0x2C */ void* dst; // data buffer
|
||||
/* 0x30 */ s32 bytesRead; // num read bytes
|
||||
/* 0x34 */ s32 unk_34;
|
||||
} XCrown; // size = 0x38
|
||||
|
||||
void func_0010BEE8(void);
|
||||
void func_0010BF08(void (*)(XCrown*), XCrown*);
|
||||
void func_0010BF50(void (*)(XCrown*));
|
||||
void func_0010BF08(void (*)(IOReadTask*), IOReadTask*);
|
||||
void func_0010BF50(void (*)(IOReadTask*));
|
||||
XOtherCrown* func_0011EEB8(s32*, s32, s32(*)(XOtherCrown*));
|
||||
void func_0011FB78(void);
|
||||
void func_0011FB98(s32 lsn, s32, char*);
|
||||
s32 func_0011FE88(u8 *data, s32 compressedLength);
|
||||
s32 func_0011FF40(char* str);
|
||||
s32 cdvd_Decompress(u8* data, s32 compressedLength);
|
||||
s32 cdvd_Hash(char* str);
|
||||
s32 func_001EE068(void);
|
||||
s32 func_00218C88(void);
|
||||
void func_00218CA0(s32);
|
||||
KingdomFile* bsearch(s32, s32*, s32, s32, void*);
|
||||
|
||||
extern vs8 D_002C1EB8;
|
||||
extern s32 D_002C2094;
|
||||
@ -38,14 +28,41 @@ extern s32 D_002C2190;
|
||||
extern s32 D_002C2194;
|
||||
extern s32 D_002C2198; // fp.size
|
||||
|
||||
extern char D_0034E340[];
|
||||
extern char D_0034E340[0x800];
|
||||
extern char D_0048B549[];
|
||||
|
||||
extern void (*D_00464380)(s32);
|
||||
extern s32 D_004DE140;
|
||||
extern char D_004EC140[];
|
||||
extern s32 D_004EC940;
|
||||
extern s32 D_004EC948;
|
||||
extern XCrown D_004EC970[16];
|
||||
// .bss
|
||||
|
||||
s32 D_004DE128;
|
||||
s32 D_004DE140;
|
||||
char D_004EC140[0x800];
|
||||
s32 D_004EC940;
|
||||
sceCdlFILE cdvd_Descriptor;
|
||||
extern IOReadTask D_004EC970[16];
|
||||
char cdvd_CbThreadStack[0x1000];
|
||||
extern s32 D_004DDC60;
|
||||
extern XOtherCrown D_004DDC68[16];
|
||||
|
||||
sceCdlFILE* cdvd_GetFileDescriptor() {
|
||||
return &cdvd_Descriptor;
|
||||
}
|
||||
|
||||
void func_0011FB78() {
|
||||
func_001224B8();
|
||||
func_001102C0();
|
||||
}
|
||||
|
||||
void func_0011FB98(u32 lbn, u32 sectors, char* buf) {
|
||||
do {
|
||||
while (sceCdDiskReady(1) != SCECdComplete || sceCdRead(lbn, sectors, buf, &D_002C2188) == SCECdErNO) {
|
||||
func_0011FB78();
|
||||
}
|
||||
// Command is not complete
|
||||
while (sceCdSync(1) != 0) {
|
||||
func_0011FB78();
|
||||
}
|
||||
} while (sceCdGetError() != 0);
|
||||
}
|
||||
|
||||
INCLUDE_ASM(const s32, "xkingdom", func_0011FC58);
|
||||
|
||||
@ -62,8 +79,8 @@ void func_0011FD08(void) {
|
||||
D_002C2190 -= 1;
|
||||
return;
|
||||
} else {
|
||||
func_0011FB98(D_004EC948, 1, D_0034E340);
|
||||
if (strncmp(D_0034E340, D_004EC140, 0x800) != 0) {
|
||||
func_0011FB98(cdvd_Descriptor.lsn, 1, D_0034E340);
|
||||
if (strncmp(D_0034E340, D_004EC140, ARRAY_COUNT(D_0034E340)) != 0) {
|
||||
D_002C2190 = 60;
|
||||
return;
|
||||
}
|
||||
@ -74,27 +91,27 @@ void func_0011FD08(void) {
|
||||
}
|
||||
}
|
||||
|
||||
XCrown* func_0011FE18(void) {
|
||||
IOReadTask* cdvd_FindFreeTask(void) {
|
||||
s32 i = 0;
|
||||
XCrown* temp = D_004EC970;
|
||||
IOReadTask* task = D_004EC970;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(D_004EC970); i++, temp++) {
|
||||
if (!(temp->flags & 1)) {
|
||||
temp->flags |= 1;
|
||||
temp->bytesRead = -1;
|
||||
temp->unk_34 = D_002C2194++;
|
||||
return temp;
|
||||
for (i = 0; i < ARRAY_COUNT(D_004EC970); i++, task++) {
|
||||
if (!(task->flags & 1)) {
|
||||
task->flags |= 1;
|
||||
task->bytesRead = -1;
|
||||
task->unk_34 = D_002C2194++;
|
||||
return task;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void func_0011FE80(XCrown* arg0) {
|
||||
arg0->flags = 0;
|
||||
void cdvd_FreeTask(IOReadTask* task) {
|
||||
task->flags = 0;
|
||||
}
|
||||
|
||||
// in-place decompression algorithm
|
||||
s32 func_0011FE88(u8* data, s32 compressedLength) {
|
||||
s32 cdvd_Decompress(u8* data, s32 compressedLength) {
|
||||
s32 copyLength;
|
||||
s32 decompressedLength;
|
||||
s32 i;
|
||||
@ -128,7 +145,7 @@ s32 func_0011FE88(u8* data, s32 compressedLength) {
|
||||
}
|
||||
|
||||
// hash
|
||||
s32 func_0011FF40(char* str) {
|
||||
s32 cdvd_Hash(char* str) {
|
||||
s32 len = strlen(str);
|
||||
s32 hash = 0;
|
||||
s32 i;
|
||||
@ -139,63 +156,62 @@ s32 func_0011FF40(char* str) {
|
||||
return hash;
|
||||
}
|
||||
|
||||
// why is left a u32 and right a u32*?
|
||||
int func_0011FFB8(const u32 left, const u32* right) {
|
||||
s32 cdvd_Compare(const u32 left, const u32* right) {
|
||||
if (left < *right) {
|
||||
return -1;
|
||||
}
|
||||
return *right < left;
|
||||
}
|
||||
|
||||
KingdomFile* func_0011FFD8(char* filename) {
|
||||
return bsearch(func_0011FF40(filename), &D_004DE140, D_002C2180, 0x10, func_0011FFB8);
|
||||
KingdomFile* cdvd_FindFile(char* filename) {
|
||||
return bsearch(cdvd_Hash(filename), &D_004DE140, D_002C2180, 0x10, cdvd_Compare);
|
||||
}
|
||||
|
||||
void func_00120018(XCrown* arg0) {
|
||||
u32 numSectors = (u32) (arg0->length + 0x7FF) >> 11;
|
||||
s32 var_17;
|
||||
void func_00120018(IOReadTask* task) {
|
||||
u32 numSectors = (u32)(task->length + 0x7FF) >> 11;
|
||||
s32 length;
|
||||
|
||||
do {
|
||||
while (TRUE) {
|
||||
if (sceCdDiskReady(1) == SCECdComplete && sceCdRead(arg0->nSector, numSectors, arg0->dst, &D_002C2188) != 0) {
|
||||
if (sceCdDiskReady(1) == SCECdComplete && sceCdRead(task->nSector, numSectors, task->dst, &D_002C2188) != 0) {
|
||||
break;
|
||||
}
|
||||
func_0010BEE8();
|
||||
}
|
||||
|
||||
|
||||
while (sceCdSync(1) != 0) {
|
||||
func_0010BEE8();
|
||||
}
|
||||
} while (sceCdGetError() != SCECdErNO);
|
||||
|
||||
if ((arg0->flags >> 1) & 1) {
|
||||
if ((task->flags >> 1) & 1) {
|
||||
FlushCache(WRITEBACK_DCACHE);
|
||||
var_17 = func_0011FE88(arg0->dst, arg0->length);
|
||||
length = cdvd_Decompress(task->dst, task->length);
|
||||
} else {
|
||||
var_17 = arg0->length;
|
||||
length = task->length;
|
||||
}
|
||||
|
||||
func_0010BF50(func_00120018);
|
||||
arg0->bytesRead = var_17;
|
||||
task->bytesRead = length;
|
||||
}
|
||||
|
||||
void func_00120108(XCrown* arg0) {
|
||||
void cdvd_ReadImgFile(IOReadTask* task) {
|
||||
s32 cond;
|
||||
s32 fd;
|
||||
s32 nbyte;
|
||||
|
||||
fd = sceOpen("pfs0:kingdom.img", SCE_RDONLY);
|
||||
fd = sceOpen("pfs0:kingdom.img\0\0\0\0", SCE_RDONLY);
|
||||
cond = FALSE;
|
||||
|
||||
|
||||
if (fd < 0 || D_002C2094 & 0x2000) {
|
||||
cond = TRUE;
|
||||
} else {
|
||||
s32 numReadBytes = 0;
|
||||
|
||||
sceLseek(fd, arg0->nSector * SECTOR_SIZE, SCE_SEEK_SET);
|
||||
sceLseek(fd, task->nSector * SECTOR_SIZE, SCE_SEEK_SET);
|
||||
|
||||
for (nbyte = arg0->length; nbyte > 0; nbyte -= numReadBytes) {
|
||||
numReadBytes = sceRead(fd, arg0->dst, nbyte);
|
||||
for (nbyte = task->length; nbyte > 0; nbyte -= numReadBytes) {
|
||||
numReadBytes = sceRead(fd, task->dst, nbyte);
|
||||
if (numReadBytes < 0) { // error
|
||||
cond = TRUE;
|
||||
break;
|
||||
@ -204,42 +220,43 @@ void func_00120108(XCrown* arg0) {
|
||||
|
||||
sceClose(fd);
|
||||
if (!cond) {
|
||||
if ((arg0->flags >> 1) & 1) {
|
||||
if ((task->flags >> 1) & 1) {
|
||||
FlushCache(WRITEBACK_DCACHE);
|
||||
numReadBytes = func_0011FE88(arg0->dst, arg0->length);
|
||||
numReadBytes = cdvd_Decompress(task->dst, task->length);
|
||||
}
|
||||
arg0->bytesRead = numReadBytes;
|
||||
task->bytesRead = numReadBytes;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (cond) {
|
||||
disk_Mgr.unk_20(4);
|
||||
D_002C1EB8 |= 4;
|
||||
do {
|
||||
func_0010BEE8();
|
||||
} while(((D_002C1EB8 & 0xFF) >> 2) & 1);
|
||||
} while (((D_002C1EB8 & 0xFF) >> 2) & 1);
|
||||
func_00218CA0(0);
|
||||
arg0->nSector += D_004EC940;
|
||||
func_0010BF08(&func_00120018, arg0);
|
||||
task->nSector += D_004EC940;
|
||||
func_0010BF08(&func_00120018, task);
|
||||
}
|
||||
func_0010BF50(func_00120108);
|
||||
func_0010BF50(cdvd_ReadImgFile);
|
||||
}
|
||||
|
||||
void func_00120280(sceCdlFILE* fp, char* name) {
|
||||
void cdvd_TryLoadFile(sceCdlFILE* fp, char* name) {
|
||||
// DVD-ROM is not ready or file was not found
|
||||
while (sceCdDiskReady(1) != SCECdComplete || sceCdSearchFile(fp, name) == 0) {
|
||||
func_0011FB78();
|
||||
}
|
||||
}
|
||||
|
||||
XCrown* func_001202E8(char* filename, void* dst) {
|
||||
XCrown* task;
|
||||
IOReadTask* func_001202E8(char* filename, void* dst) {
|
||||
IOReadTask* task;
|
||||
KingdomFile* kingdomFile;
|
||||
|
||||
task = func_0011FE18();
|
||||
task = cdvd_FindFreeTask();
|
||||
task->dst = dst;
|
||||
task->bytesRead = -1;
|
||||
|
||||
kingdomFile = func_0011FFD8(filename);
|
||||
|
||||
kingdomFile = cdvd_FindFile(filename);
|
||||
if (kingdomFile == NULL) {
|
||||
task->bytesRead = 0;
|
||||
} else {
|
||||
@ -250,17 +267,17 @@ XCrown* func_001202E8(char* filename, void* dst) {
|
||||
func_0010BF08(func_00120018, task);
|
||||
} else {
|
||||
task->nSector -= D_004EC940;
|
||||
func_0010BF08(func_00120108, task);
|
||||
func_0010BF08(cdvd_ReadImgFile, task);
|
||||
}
|
||||
}
|
||||
return task;
|
||||
}
|
||||
|
||||
s32 func_001203C8(char* arg0, char* arg1) {
|
||||
s32 func_001203C8(char* name, char* buf) {
|
||||
sceCdlFILE fp;
|
||||
|
||||
func_00120280(&fp, arg0);
|
||||
func_0011FB98(fp.lsn, (fp.size + 0x7FF) >> 11, arg1);
|
||||
cdvd_TryLoadFile(&fp, name);
|
||||
func_0011FB98(fp.lsn, (fp.size + 0x7FF) >> 11, buf);
|
||||
D_002C2198 = fp.size;
|
||||
FlushCache(WRITEBACK_DCACHE);
|
||||
FlushCache(INVALIDATE_ICACHE);
|
||||
@ -269,36 +286,163 @@ s32 func_001203C8(char* arg0, char* arg1) {
|
||||
|
||||
s32 func_00120438(const char* fileName, void* dst);
|
||||
INCLUDE_ASM(const s32, "xkingdom", func_00120438);
|
||||
// s32 func_00120438(char* arg0, void* arg1) {
|
||||
// XCrown* temp_2 = func_001202E8(arg0, arg1);
|
||||
// s32 func_00120438(char* filename, void* arg1) {
|
||||
// IOReadTask* temp_2 = func_001202E8(filename, arg1);
|
||||
|
||||
// while (temp_2->unk_30 < 0) {
|
||||
// while (temp_2->bytesRead < 0) {
|
||||
// func_0011FB78();
|
||||
// }
|
||||
|
||||
// D_002C2198 = temp_2->unk_30;
|
||||
// func_0011FE80(temp_2);
|
||||
|
||||
// D_002C2198 = temp_2->bytesRead;
|
||||
// cdvd_FreeTask(temp_2);
|
||||
// FlushCache(WRITEBACK_DCACHE);
|
||||
// FlushCache(INVALIDATE_ICACHE);
|
||||
// return D_002C2198;
|
||||
// }
|
||||
|
||||
void func_001204C0(void);
|
||||
INCLUDE_ASM(const s32, "xkingdom", func_001204C0);
|
||||
|
||||
INCLUDE_ASM(const s32, "xkingdom", func_00120590);
|
||||
s32 func_00120590(char* arg0, s32 arg1, s32 arg2, s32 arg3) {
|
||||
XOtherCrown* temp_2 = func_0011EEB8(&D_004DE128, 0, func_001204C0);
|
||||
s32* new_var2 = &D_004DDC60; // TODO fake match
|
||||
s32* new_var;
|
||||
|
||||
temp_2->unk_44 = D_004DDC60++;
|
||||
temp_2->unk_40 = arg3;
|
||||
strcpy(temp_2->unk_10, arg0);
|
||||
temp_2->unk_38 = arg1;
|
||||
temp_2->unk_3C = arg2;
|
||||
D_004DDC60 = (u16) *new_var2;
|
||||
|
||||
new_var = &temp_2->unk_44; // TODO fake match
|
||||
return *new_var;
|
||||
}
|
||||
|
||||
INCLUDE_ASM(const s32, "xkingdom", func_00120640);
|
||||
s32 func_00120640(s32 arg0) {
|
||||
XOtherCrown* it = &D_004DDC68[0];
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(D_004DDC68); i++, it++) {
|
||||
if (func_0011F0F8(it) && (arg0 == -1 || arg0 == it->unk_44)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void func_001206D0(char* filename) {
|
||||
void cdvd_Seek(char* filename) {
|
||||
// Confirm disk status allows commands to be sent
|
||||
if (sceCdDiskReady(1) == SCECdComplete) {
|
||||
KingdomFile* kingdomFile = func_0011FFD8(filename);
|
||||
|
||||
KingdomFile* kingdomFile = cdvd_FindFile(filename);
|
||||
if (kingdomFile != NULL) {
|
||||
// Seek DVD-ROM head to specified block then pause
|
||||
sceCdSeek(kingdomFile->isoBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INCLUDE_ASM(const s32, "xkingdom", func_00120728);
|
||||
void func_00120728(s32 arg0) {
|
||||
func_0011EEB8(&D_004DE128, 0, arg0);
|
||||
}
|
||||
|
||||
INCLUDE_ASM(const s32, "xkingdom", func_00120750);
|
||||
s32 func_00120750() {
|
||||
func_0011EF58(&D_004DE128, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* cdvd_GetFileName(char* arg0) {
|
||||
static char D_0048DB00[0x50140]; // TODO REMOVE THIS
|
||||
|
||||
static char D_004DDC40[0x100];
|
||||
|
||||
s32 len;
|
||||
s32 i;
|
||||
char* new_var5;
|
||||
s32 blah;
|
||||
|
||||
strcpy(D_004DDC40, "cdrom0:\\");
|
||||
strcat(D_004DDC40, arg0);
|
||||
len = strlen(D_004DDC40);
|
||||
|
||||
for (i = 8; i < len; i++) {
|
||||
blah = D_004DDC40[i];
|
||||
|
||||
if ((new_var5 = D_0048B549)[blah] & 2) {
|
||||
blah -= 0x20;
|
||||
}
|
||||
|
||||
D_004DDC40[i] = blah;
|
||||
}
|
||||
return D_004DDC40;
|
||||
}
|
||||
|
||||
void cdvd_TryLoadModule(char* file) {
|
||||
s32 loadStatus;
|
||||
|
||||
char* module = cdvd_GetFileName(file);
|
||||
// Retry until module is loaded
|
||||
do {
|
||||
loadStatus = sceSifLoadModule(module, 0, NULL);
|
||||
} while (loadStatus < 0);
|
||||
}
|
||||
|
||||
s32 cdvd_StartModule(char* file, s32 args, char* argp, s32* result) {
|
||||
char* module = cdvd_GetFileName(file);
|
||||
// Load and execute module in IOP memory
|
||||
return sceSifLoadStartModule(module, args, argp, result);
|
||||
}
|
||||
|
||||
void func_001208B8() {
|
||||
s32 val = func_0011ED30(185000, func_00120750);
|
||||
*(s16*)(val + 2) = -1;
|
||||
}
|
||||
|
||||
void func_001208E8() {
|
||||
IOReadTask* task;
|
||||
s32 i;
|
||||
|
||||
func_0011EDD0(&D_004DE128, &D_004DDC68, 0x4C, 0x10);
|
||||
task = D_004EC970;
|
||||
D_004DDC60 = 0;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(D_004EC970); i++) {
|
||||
cdvd_FreeTask(task);
|
||||
task++;
|
||||
}
|
||||
}
|
||||
|
||||
s32 cdvd_Initialize() {
|
||||
s32 val;
|
||||
|
||||
// Initialize SIF RPC API
|
||||
sceSifInitRpc(0);
|
||||
sceFsReset();
|
||||
// Initialize the DVD-ROM subsystem
|
||||
sceCdInit(0);
|
||||
sceCdMmode(2);
|
||||
|
||||
// Attempt to reboot IOP system until successful
|
||||
do {
|
||||
val = sceSifRebootIop("cdrom0:\\IOPRP243.IMG");
|
||||
} while (val == 0);
|
||||
// Attempt to confirm IOP was rebooted until successful
|
||||
do {
|
||||
val = sceSifSyncIop();
|
||||
} while (val == 0);
|
||||
|
||||
// Initialize SIF RPC API
|
||||
sceSifInitRpc(0);
|
||||
sceCdInit(0);
|
||||
sceCdMmode(2);
|
||||
// Initialize callback thread
|
||||
return sceCdInitEeCB(0, &cdvd_CbThreadStack, 0x1000);
|
||||
}
|
||||
|
||||
void func_001209E0() {
|
||||
sceCdDiskReady(0);
|
||||
cdvd_TryLoadFile(&cdvd_Descriptor, "\\SYSTEM.CNF;1");
|
||||
func_0011FB98(cdvd_Descriptor.lsn, 1, D_004EC140);
|
||||
sceCdSync(0);
|
||||
func_0011FC58();
|
||||
}
|
||||
|
@ -18,6 +18,23 @@ _exit = 0x001000b8; // type:func
|
||||
main = 0x00100438; // type:func
|
||||
|
||||
//=============================
|
||||
// cdvd.c
|
||||
//=============================
|
||||
cdvd_GetFileDescriptor = 0x0011FB68; // type:func
|
||||
cdvd_FindFreeTask = 0x0011FE18; // type:func
|
||||
cdvd_FreeTask = 0x0011FE80; // type:func
|
||||
cdvd_Decompress = 0x0011FE88; // type:func
|
||||
cdvd_Hash = 0x0011FF40; // type:func
|
||||
cdvd_Compare = 0x0011FFB8; // type:func
|
||||
cdvd_FindFile = 0x0011FFD8; // type:func
|
||||
cdvd_ReadImgFile = 0x00120108; // type:func
|
||||
cdvd_TryLoadFile = 0x00120280; // type:func
|
||||
cdvd_Seek = 0x001206D0; // type:func
|
||||
cdvd_GetFileName = 0x00120778; // type:func
|
||||
cdvd_TryLoadModule = 0x00120820; // type:func
|
||||
cdvd_StartModule = 0x00120868; // type:func
|
||||
cdvd_Initialize = 0x00120958; // type:func
|
||||
|
||||
// ppp lib
|
||||
//=============================
|
||||
// pppKeThRes.c
|
||||
@ -2002,6 +2019,12 @@ _fs_semid = 0x00465364; //type:s32
|
||||
_fs_iob_semid = 0x00465368; //type:s32
|
||||
_fs_fsq_semid = 0x0046536C; //type:s32
|
||||
|
||||
//=============================
|
||||
// cdvd.c
|
||||
//=============================
|
||||
cdvd_Descriptor = 0x004EC948; // type:char
|
||||
cdvd_CbThreadStack = 0x004ECCF0; // size:0x1000
|
||||
|
||||
//=============================
|
||||
// ppp lib
|
||||
//=============================
|
||||
|
Loading…
x
Reference in New Issue
Block a user