mirror of
https://github.com/Xeeynamo/sotn-decomp.git
synced 2024-11-23 04:59:41 +00:00
Decompile main (#1326)
Decompiles `main`. Co-authored-by: Jonathan Hohle <jon@ttkb.co>
This commit is contained in:
parent
b01fe2b36b
commit
32f42645d5
@ -1,3 +1,6 @@
|
||||
D_80010960 = 0x80010960; // force_migration:True
|
||||
D_80010964 = 0x80010964; // force_migration:True
|
||||
main_fd = 0x800339F8;
|
||||
main_cdlFile = 0x800339FC;
|
||||
main_cdlMode = 0x80033A14;
|
||||
g_MainGame = 0x800A0000;
|
||||
|
@ -185,6 +185,7 @@ typedef struct Prim {
|
||||
#define WEAPON_1_START 0xF0
|
||||
|
||||
#ifndef VERSION_PC
|
||||
#define DRA_PRG_PTR 0x800A0000
|
||||
#define RIC_PRG_PTR 0x8013C000
|
||||
#define FAMILIAR_PTR 0x80170000
|
||||
#define WEAPON0_PTR 0x8017A000
|
||||
@ -199,6 +200,7 @@ typedef struct Prim {
|
||||
#define SIM_PTR 0x80280000
|
||||
|
||||
#else
|
||||
#define DRA_PRG_PTR 0x800A0000
|
||||
#define RIC_PRG_PTR 0x8013C000
|
||||
#define FAMILIAR_PTR 0x80170000
|
||||
#define WEAPON0_PTR 0x8017A000
|
||||
@ -334,6 +336,7 @@ typedef enum {
|
||||
Game_PrologueEnd,
|
||||
Game_MainMenu,
|
||||
Game_Ending,
|
||||
Game_Boot,
|
||||
Game_99 = 99,
|
||||
} GameState;
|
||||
|
||||
|
@ -1,5 +1,76 @@
|
||||
#include "common.h"
|
||||
#include "game.h"
|
||||
|
||||
INCLUDE_ASM("main/nonmatchings/main", main);
|
||||
extern void (*g_MainGame)();
|
||||
extern CdlFILE main_cdlFile;
|
||||
extern u8 main_cdlMode[];
|
||||
extern s32 main_fd;
|
||||
|
||||
void main(void) {
|
||||
ResetCallback();
|
||||
InitHeap((void*)0x801F0000, 0x7800);
|
||||
CdInit();
|
||||
|
||||
g_GameState = Game_Boot;
|
||||
|
||||
do {
|
||||
main_fd = open("sim:c:\\bin\\dra.bin", 1);
|
||||
} while (main_fd == -1 && --g_GameState != Game_Init);
|
||||
|
||||
if (g_GameState != Game_Init) {
|
||||
read(main_fd, (void*)DRA_PRG_PTR, 0x130000);
|
||||
close(main_fd);
|
||||
g_UseDisk = 0;
|
||||
main_fd = open("sim:c:\\bin\\dra.bio", 1);
|
||||
|
||||
if (main_fd != -1) {
|
||||
g_UseDisk = 2;
|
||||
}
|
||||
|
||||
do {
|
||||
main_fd = open("sim:c:\\bin\\f_map.bin", 1);
|
||||
} while (main_fd < 0);
|
||||
|
||||
read(main_fd, (void*)CASTLE_MAP_PTR, 0x8000);
|
||||
close(main_fd);
|
||||
} else {
|
||||
main_search_loop_1:
|
||||
while (!CdSearchFile(&main_cdlFile, "\\DRA.BIN;1")) {
|
||||
}
|
||||
|
||||
*main_cdlMode = CdlModeSpeed | CdlModeSpeedNormal;
|
||||
CdControl(CdlSetmode, main_cdlMode, NULL);
|
||||
|
||||
while (CdSync(1, NULL) != 2) {
|
||||
}
|
||||
|
||||
g_GameState = (main_cdlFile.size + 0x7ff) >> 0xB;
|
||||
CdControl(CdlSetloc, &main_cdlFile, NULL);
|
||||
CdRead(g_GameState, (u32*)DRA_PRG_PTR, 0x80);
|
||||
// block until read is complete
|
||||
main_fd = CdReadSync(0, NULL);
|
||||
if (main_fd < 0) {
|
||||
goto main_search_loop_1;
|
||||
}
|
||||
|
||||
g_UseDisk = 1;
|
||||
|
||||
main_search_loop_2:
|
||||
if (!CdSearchFile(&main_cdlFile, "\\F_MAP.BIN;1")) {
|
||||
goto main_search_loop_2;
|
||||
} else {
|
||||
g_GameState = (main_cdlFile.size + 0x7ff) >> 0xB;
|
||||
}
|
||||
CdControl(CdlSetloc, &main_cdlFile, NULL);
|
||||
CdRead(g_GameState, (u32*)CASTLE_MAP_PTR, 0x80);
|
||||
// block until read is complete
|
||||
main_fd = CdReadSync(0, NULL);
|
||||
|
||||
if (main_fd < 0) {
|
||||
goto main_search_loop_2;
|
||||
}
|
||||
}
|
||||
g_MainGame();
|
||||
}
|
||||
|
||||
const char a0123456789abcd[] = "0123456789ABCDEF\0\0\0\0";
|
||||
|
Loading…
Reference in New Issue
Block a user