Merge branch 'main' of https://github.com/Rainchus/mp4-dtk into main

This commit is contained in:
CreateSource 2023-11-23 14:05:26 -05:00
commit c7189d056b
14 changed files with 731 additions and 198 deletions

View file

@ -5,3 +5,12 @@ Sections:
.rodata type:rodata align:8
.data type:data align:8
.bss type:bss align:8
REL/executor.c:
.text start:0x00000000 end:0x000000A0
REL/subchrselDll/subchrselDll.c:
.text start:0x000000A0 end:0x000007B8
.rodata start:0x00000000 end:0x00000018
.data start:0x00000000 end:0x000000E1
.bss start:0x00000000 end:0x00000004

View file

@ -1,33 +1,33 @@
_prolog = .text:0x00000000; // type:function size:0x54 scope:global
_epilog = .text:0x00000054; // type:function size:0x4C scope:global
fn_1_A0 = .text:0x000000A0; // type:function size:0x6C
fn_1_10C = .text:0x0000010C; // type:function size:0x58
fn_1_164 = .text:0x00000164; // type:function size:0x654
ModuleProlog = .text:0x000000A0; // type:function size:0x6C
GetBtns = .text:0x0000010C; // type:function size:0x58 scope:local
SubchrMain = .text:0x00000164; // type:function size:0x654 scope:local
_ctors = .ctors:0x00000000; // type:label scope:global data:4byte
_dtors = .dtors:0x00000000; // type:label scope:global data:4byte
lbl_1_rodata_10 = .rodata:0x00000010; // type:object size:0x4 data:float
lbl_1_rodata_14 = .rodata:0x00000014; // type:object size:0x4 data:float
lbl_1_data_0 = .data:0x00000000; // type:object size:0x8 data:string
lbl_1_data_8 = .data:0x00000008; // type:object size:0x8 data:string
lbl_1_data_10 = .data:0x00000010; // type:object size:0x8 data:string
lbl_1_data_18 = .data:0x00000018; // type:object size:0x8 data:string
lbl_1_data_20 = .data:0x00000020; // type:object size:0x10
lbl_1_data_30 = .data:0x00000030; // type:object size:0x6 data:string
lbl_1_data_36 = .data:0x00000036; // type:object size:0x6 data:string
lbl_1_data_3C = .data:0x0000003C; // type:object size:0x6 data:string
lbl_1_data_42 = .data:0x00000042; // type:object size:0x6 data:string
lbl_1_data_48 = .data:0x00000048; // type:object size:0x6 data:string
lbl_1_data_4E = .data:0x0000004E; // type:object size:0x7 data:string
lbl_1_data_55 = .data:0x00000055; // type:object size:0x6 data:string
lbl_1_data_5B = .data:0x0000005B; // type:object size:0x9
lbl_1_data_64 = .data:0x00000064; // type:object size:0x20
lbl_1_data_84 = .data:0x00000084; // type:object size:0x1
lbl_1_data_85 = .data:0x00000085; // type:object size:0x6 data:string
lbl_1_data_8B = .data:0x0000008B; // type:object size:0x8 data:string
lbl_1_data_93 = .data:0x00000093; // type:object size:0x7 data:string
lbl_1_data_9A = .data:0x0000009A; // type:object size:0x7 data:string
lbl_1_data_A1 = .data:0x000000A1; // type:object size:0x6 data:string
lbl_1_data_A7 = .data:0x000000A7; // type:object size:0x9
lbl_1_data_B0 = .data:0x000000B0; // type:object size:0x1C
lbl_1_data_CC = .data:0x000000CC; // type:object size:0x15 data:string
lbl_1_bss_0 = .bss:0x00000000; // type:object size:0x4 data:byte
lbl_1_rodata_10 = .rodata:0x00000010; // type:object size:0x4 scope:local data:float
lbl_1_rodata_14 = .rodata:0x00000014; // type:object size:0x4 scope:local data:float
lbl_1_data_0 = .data:0x00000000; // type:object size:0x8 scope:local data:string
lbl_1_data_8 = .data:0x00000008; // type:object size:0x8 scope:local data:string
lbl_1_data_10 = .data:0x00000010; // type:object size:0x8 scope:local data:string
lbl_1_data_18 = .data:0x00000018; // type:object size:0x8 scope:local data:string
player_numstr = .data:0x00000020; // type:object size:0x10 scope:local
lbl_1_data_30 = .data:0x00000030; // type:object size:0x6 scope:local data:string
lbl_1_data_36 = .data:0x00000036; // type:object size:0x6 scope:local data:string
lbl_1_data_3C = .data:0x0000003C; // type:object size:0x6 scope:local data:string
lbl_1_data_42 = .data:0x00000042; // type:object size:0x6 scope:local data:string
lbl_1_data_48 = .data:0x00000048; // type:object size:0x6 scope:local data:string
lbl_1_data_4E = .data:0x0000004E; // type:object size:0x7 scope:local data:string
lbl_1_data_55 = .data:0x00000055; // type:object size:0x6 scope:local data:string
lbl_1_data_5B = .data:0x0000005B; // type:object size:0x9 scope:local
character_str = .data:0x00000064; // type:object size:0x20 scope:local
lbl_1_data_84 = .data:0x00000084; // type:object size:0x1 scope:local
lbl_1_data_85 = .data:0x00000085; // type:object size:0x6 scope:local data:string
lbl_1_data_8B = .data:0x0000008B; // type:object size:0x8 scope:local data:string
lbl_1_data_93 = .data:0x00000093; // type:object size:0x7 scope:local data:string
lbl_1_data_9A = .data:0x0000009A; // type:object size:0x7 scope:local data:string
lbl_1_data_A1 = .data:0x000000A1; // type:object size:0x6 scope:local data:string
lbl_1_data_A7 = .data:0x000000A7; // type:object size:0x9 scope:local
ext_character_str = .data:0x000000B0; // type:object size:0x1C scope:local
lbl_1_data_CC = .data:0x000000CC; // type:object size:0x15 scope:local data:string
lbl_1_bss_0 = .bss:0x00000000; // type:object size:0x4 scope:local data:byte

View file

@ -44,6 +44,12 @@ game/decode.c:
.data start:0x8011FDE0 end:0x8011FE00
.bss start:0x80145640 end:0x80145A40
game/font.c:
.data start:0x8011FE00 end:0x80121E00
game/jmp.c:
.text start:0x8000A464 end:0x8000A558
game/malloc.c:
.text start:0x8000A558 end:0x8000A938
.data start:0x80121F50 end:0x80121FC8
@ -53,6 +59,19 @@ game/memory.c:
.text start:0x8000A938 end:0x8000AEF0
.data start:0x80121FC8 end:0x80122140
game/printfunc.c:
.text start:0x8000AEF0 end:0x8000C4A4
.data start:0x80122140 end:0x80122180
.bss start:0x80145A98 end:0x8014C398
.sbss start:0x801D3B28 end:0x801D3B38
.sdata2 start:0x801D4978 end:0x801D49C8
game/process.c:
.text start:0x8000C4A4 end:0x8000D348
.data start:0x80122180 end:0x801221D0
.bss start:0x8014C398 end:0x8014C490
.sbss start:0x801D3B38 end:0x801D3B48
game/sprman.c:
.text start:0x8000D348 end:0x8000F6A0
.rodata start:0x8011DD00 end:0x8011DD10

View file

@ -99,8 +99,8 @@ fn_80009FF8 = .text:0x80009FF8; // type:function size:0xE4
fn_8000A0DC = .text:0x8000A0DC; // type:function size:0xC8
fn_8000A1A4 = .text:0x8000A1A4; // type:function size:0x6C
fn_8000A210 = .text:0x8000A210; // type:function size:0x254
fn_8000A464 = .text:0x8000A464; // type:function size:0x74
fn_8000A4D8 = .text:0x8000A4D8; // type:function size:0x80
gcsetjmp = .text:0x8000A464; // type:function size:0x74
gclongjmp = .text:0x8000A4D8; // type:function size:0x80
HuMemInitAll = .text:0x8000A558; // type:function size:0x12C
HuMemInit = .text:0x8000A684; // type:function size:0x30
HuMemDCFlushAll = .text:0x8000A6B4; // type:function size:0x2C
@ -124,12 +124,12 @@ HuMemUsedMemoryBlockGet = .text:0x8000ACF8; // type:function size:0x44
HuMemMemoryAllocSizeGet = .text:0x8000AD3C; // type:function size:0xC
HuMemHeapDump = .text:0x8000AD48; // type:function size:0x158
HuMemMemorySizeGet = .text:0x8000AEA0; // type:function size:0x50
fn_8000AEF0 = .text:0x8000AEF0; // type:function size:0x64
fn_8000AF54 = .text:0x8000AF54; // type:function size:0xA0
fn_8000AFF4 = .text:0x8000AFF4; // type:function size:0x15C
DrawBox = .text:0x8000B150; // type:function size:0xAC
fn_8000B1FC = .text:0x8000B1FC; // type:function size:0xEE8
fn_8000C0E4 = .text:0x8000C0E4; // type:function size:0x3C0
pfInit = .text:0x8000AEF0; // type:function size:0x64
pfClsScr = .text:0x8000AF54; // type:function size:0xA0
print8 = .text:0x8000AFF4; // type:function size:0x15C
printWin = .text:0x8000B150; // type:function size:0xAC
pfDrawFonts = .text:0x8000B1FC; // type:function size:0xEE8
WireDraw = .text:0x8000C0E4; // type:function size:0x3C0 scope:local
HuPrcInit = .text:0x8000C4A4; // type:function size:0x14
HuPrcCreate = .text:0x8000C4B8; // type:function size:0x1E8
HuPrcChildLink = .text:0x8000C6A0; // type:function size:0x68
@ -511,8 +511,8 @@ fn_8002EA6C = .text:0x8002EA6C; // type:function size:0x16C
fn_8002EBD8 = .text:0x8002EBD8; // type:function size:0x90
fn_8002EC68 = .text:0x8002EC68; // type:function size:0x170
fn_8002EDD8 = .text:0x8002EDD8; // type:function size:0xE8
fn_8002EEC0 = .text:0x8002EEC0; // type:function size:0x60
fn_8002EF20 = .text:0x8002EF20; // type:function size:0xF4
omOvlGotoEx = .text:0x8002EEC0; // type:function size:0x60
omOvlReturnEx = .text:0x8002EF20; // type:function size:0xF4
fn_8002F014 = .text:0x8002F014; // type:function size:0xB8
omOvlHisChg = .text:0x8002F0CC; // type:function size:0xA0
omOvlHisGet = .text:0x8002F16C; // type:function size:0x78
@ -728,7 +728,7 @@ fn_80040D60 = .text:0x80040D60; // type:function size:0x36C
fn_800410CC = .text:0x800410CC; // type:function size:0xA4
fn_80041170 = .text:0x80041170; // type:function size:0xB4
fn_80041224 = .text:0x80041224; // type:function size:0x288
fn_800414AC = .text:0x800414AC; // type:function size:0x12C
WipeCreate = .text:0x800414AC; // type:function size:0x12C
fn_800415D8 = .text:0x800415D8; // type:function size:0x28
fn_80041600 = .text:0x80041600; // type:function size:0x10
fn_80041610 = .text:0x80041610; // type:function size:0x8
@ -4838,7 +4838,7 @@ lbl_8011FC68 = .data:0x8011FC68; // type:object size:0x3C
lbl_8011FCA4 = .data:0x8011FCA4; // type:object size:0x1A data:string
lbl_8011FCBE = .data:0x8011FCBE; // type:object size:0x122
lbl_8011FDE0 = .data:0x8011FDE0; // type:object size:0x20
lbl_8011FE00 = .data:0x8011FE00; // type:object size:0x2000
ank8x8_4b = .data:0x8011FE00; // type:object size:0x2000 align:32
lbl_80121E00 = .data:0x80121E00; // type:object size:0x150
HeapSizeTbl = .data:0x80121F50; // type:object size:0x78 scope:local
lbl_80121FC8 = .data:0x80121FC8; // type:object size:0x50
@ -5357,9 +5357,9 @@ ReadDataStat = .bss:0x80142840; // type:object size:0x2E00 align:32 data:4byte
TextBuffer = .bss:0x80145640; // type:object size:0x400
lbl_80145A40 = .bss:0x80145A40; // type:object size:0x40
HeapTbl = .bss:0x80145A80; // type:object size:0x14 scope:local
lbl_80145A98 = .bss:0x80145A98; // type:object size:0x6800
lbl_8014C298 = .bss:0x8014C298; // type:object size:0x100 data:byte
lbl_8014C398 = .bss:0x8014C398; // type:object size:0xF8
strline = .bss:0x80145A98; // type:object size:0x6800 scope:local
pfStrBuf = .bss:0x8014C298; // type:object size:0x100 scope:local data:byte
processjmpbuf = .bss:0x8014C398; // type:object size:0xF8 align:8
HuSprData = .bss:0x8014C490; // type:object size:0x9600
HuSprGrpData = .bss:0x80155A90; // type:object size:0x5400 data:2byte
HuSprOrder = .bss:0x8015AE90; // type:object size:0x1800
@ -5400,7 +5400,7 @@ lbl_8018F790 = .bss:0x8018F790; // type:object size:0x370
lbl_8018FB00 = .bss:0x8018FB00; // type:object size:0x38
lbl_8018FB38 = .bss:0x8018FB38; // type:object size:0xC0
lbl_8018FBF8 = .bss:0x8018FBF8; // type:object size:0x18
lbl_8018FC10 = .bss:0x8018FC10; // type:object size:0x28
gPlayerConfig = .bss:0x8018FC10; // type:object size:0x28
gPlayerData = .bss:0x8018FC38; // type:object size:0xC0 data:byte
lbl_8018FCF8 = .bss:0x8018FCF8; // type:object size:0xE0 data:byte
lbl_8018FDD8 = .bss:0x8018FDD8; // type:object size:0x230
@ -5419,8 +5419,8 @@ lbl_80190E60 = .bss:0x80190E60; // type:object size:0x1200 data:4byte
lbl_80192060 = .bss:0x80192060; // type:object size:0x100
lbl_80192160 = .bss:0x80192160; // type:object size:0x100
lbl_80192260 = .bss:0x80192260; // type:object size:0x100
lbl_80192360 = .bss:0x80192360; // type:object size:0x60 data:4byte
winData = .bss:0x801923C0; // type:object size:0x3000 data:byte
wipeData = .bss:0x80192360; // type:object size:0x60 data:4byte
winData = .bss:0x801923C0; // type:object size:0x3000 align:32 data:byte
lbl_801953C0 = .bss:0x801953C0; // type:object size:0x10
lbl_801953D0 = .bss:0x801953D0; // type:object size:0x1410
lbl_801967E0 = .bss:0x801967E0; // type:object size:0x400 data:byte
@ -5954,14 +5954,14 @@ lbl_801D3B14 = .sbss:0x801D3B14; // type:object size:0x4 data:4byte
lbl_801D3B18 = .sbss:0x801D3B18; // type:object size:0x4 data:4byte
currentHeapHandle = .sbss:0x801D3B1C; // type:object size:0x4 data:4byte
lbl_801D3B20 = .sbss:0x801D3B20; // type:object size:0x8 data:4byte
lbl_801D3B28 = .sbss:0x801D3B28; // type:object size:0x4 data:4byte
lbl_801D3B2C = .sbss:0x801D3B2C; // type:object size:0x2 data:2byte
lbl_801D3B2E = .sbss:0x801D3B2E; // type:object size:0x2 data:2byte
debugFontColor = .sbss:0x801D3B30; // type:object size:0x8 data:4byte
lbl_801D3B38 = .sbss:0x801D3B38; // type:object size:0x4 data:4byte
lbl_801D3B3C = .sbss:0x801D3B3C; // type:object size:0x2 data:2byte
lbl_801D3B40 = .sbss:0x801D3B40; // type:object size:0x4 data:4byte
lbl_801D3B44 = .sbss:0x801D3B44; // type:object size:0x4 data:4byte
saftyFrameF = .sbss:0x801D3B28; // type:object size:0x4 data:4byte
strlinecnt = .sbss:0x801D3B2C; // type:object size:0x2 data:2byte
empstrline = .sbss:0x801D3B2E; // type:object size:0x2 data:2byte
fontcolor = .sbss:0x801D3B30; // type:object size:0x8 data:4byte
procfunc = .sbss:0x801D3B38; // type:object size:0x4 data:4byte
processcnt = .sbss:0x801D3B3C; // type:object size:0x2 scope:local data:2byte
processcur = .sbss:0x801D3B40; // type:object size:0x4 scope:local data:4byte
processtop = .sbss:0x801D3B44; // type:object size:0x4 scope:local data:4byte
HuSprPauseF = .sbss:0x801D3B48; // type:object size:0x4 data:4byte
HuSprOrderNo = .sbss:0x801D3B4C; // type:object size:0x2 data:2byte
HuSprOrderNum = .sbss:0x801D3B4E; // type:object size:0x2 data:2byte

View file

@ -173,14 +173,17 @@ cflags_runtime = [
cflags_rel = [
*cflags_base,
"-O0,s",
"-char unsigned",
"-sdata 0",
"-sdata2 0",
"-pool off",
]
# Game flags
cflags_game = [
*cflags_base,
"-O0,p",
"-char unsigned",
]
config.linker_version = "GC/2.6"
@ -227,8 +230,12 @@ config.libs = [
Object(NonMatching, "game/dvd.c"),
Object(NonMatching, "game/data.c"),
Object(Matching, "game/decode.c"),
Object(NonMatching, "game/font.c"),
Object(NonMatching, "game/jmp.c"),
Object(Matching, "game/malloc.c"),
Object(Matching, "game/memory.c"),
Object(NonMatching, "game/printfunc.c"),
Object(Matching, "game/process.c"),
Object(NonMatching, "game/sprman.c"),
Object(NonMatching, "game/sprput.c"),
],
@ -263,6 +270,16 @@ config.libs = [
Object(Matching, "REL/_minigameDLL/_minigameDLL.c"),
],
},
{
"lib": "subchrselDll",
"mw_version": config.linker_version,
"cflags": cflags_rel,
"host": False,
"objects": [
Object(Matching, "REL/executor.c"),
Object(Matching, "REL/subchrselDll/subchrselDll.c"),
],
},
]
if args.mode == "configure":

View file

@ -4,5 +4,6 @@
#include "types.h"
#include "common_structs.h"
#include "functions.h"
#include "variables.h"
#endif

View file

@ -15,19 +15,46 @@ typedef struct Vec3f {
f32 z;
} Vec3f;
typedef struct unkStruct145A98 {
s16 unk_00;
char unk_02[10];
s16 unk_0C;
char unk_0E[6];
u8 unk_14;
char unk_15[0x53];
} unkStruct145A98; // sizeof 0x68
typedef struct jump_buf {
u32 lr;
u32 cr;
u32 sp;
u32 r2;
u32 pad;
u32 regs[19];
double flt_regs[19];
} jmp_buf;
typedef struct unkStruct1D3B44 {
struct unkStruct1D3B44 *prev;
char unk_04[0x1A];
u16 unk_1E;
} unkStruct1D3B44; // sizeof ???
typedef struct process {
struct process *next;
struct process *prev;
struct process *child;
struct process *parent;
struct process *next_child;
struct process *first_child;
void *heap;
u16 exec;
u16 stat;
u16 prio;
s32 sleep_time;
u32 base_sp;
jmp_buf jump;
void (*dtor)(void);
void *user_data;
} Process;
typedef struct player_config {
s16 character;
s16 pad_idx;
s16 diff;
s16 group;
s16 iscom;
} PlayerConfig;
typedef struct wipe_state {
u8 unk[52];
float duration;
u8 unk2[20];
} WipeState;
#endif

View file

@ -4,10 +4,6 @@
#include "types.h"
#include "common_structs.h"
void* HuPrcCreate(void (*), s32, s32, s32);
void HuPrcSleep(s32, f32);
void HuPrcVSleep(void);
s32* HuPrcCurrentGet(void);
void Hu3DBGColorSet(u8, u8, u8);
void Hu3DCameraCreate(s16);
void Hu3DCameraPerspectiveSet(s16, f32, f32, f32, f32);
@ -18,7 +14,8 @@ void* omInitObjMan(s32, s32);
void fn_80044920(s16);
void fn_80045F74(s16, s32);
s32 fn_800578E4(void);
void fn_1_26C(void);
void fn_80032A58(int arg0);
void fn_80035A0C(void);
void HuDecodeData(void *src, void *dst, u32 size, int decode_type);
void HuMemInitAll(void);
@ -44,6 +41,32 @@ s32 HuMemUsedMemoryBlockGet(void *heap_ptr);
s32 HuMemMemoryAllocSizeGet(s32 size);
void HuMemHeapDump(void *heap_ptr, s16 status);
void HuPrcInit(void);
Process *HuPrcCreate(void (*func)(void), u16 prio, u32 stack_size, s32 extra_size);
void HuPrcChildLink(Process *parent, Process *child);
void HuPrcChildUnlink(Process *process);
Process *HuPrcChildCreate(void (*func)(void), u16 prio, u32 stack_size, s32 extra_size, Process *parent);
void HuPrcChildWatch();
Process *HuPrcCurrentGet(void);
int HuPrcKill(Process *process);
void HuPrcChildKill(Process *process);
void HuPrcSleep(s32 time);
void HuPrcVSleep(void);
void HuPrcWakeup(Process *process);
void HuPrcDestructorSet2(Process *process, void (*func)(void));
void HuPrcDestructorSet(void (*func)(void));
void HuPrcCall(int tick);
void *HuPrcMemAlloc(s32 size);
void HuPrcMemFree(void *ptr);
void HuPrcSetStat(Process *process, u16 value);
void HuPrcResetStat(Process *process, u16 value);
void HuPrcAllPause(int flag);
void HuPrcAllUPause(int flag);
void omOvlGotoEx(int id, s16 end_mode, int stat, int event);
void omOvlReturnEx(int level, s16 end_mode);
void WipeCreate(char dir, char type, short duration);
u16 print8(s16 x, s16 y, float scale, char *str, ...);
#endif

23
include/variables.h Normal file
View file

@ -0,0 +1,23 @@
#ifndef _VARIABLES_H
#define _VARIABLES_H
#include "types.h"
#include "common_structs.h"
#include "dolphin/os.h"
extern u16 HuPadBtnDown[4];
extern u8 HuPadDStk[4];
extern OSHeapHandle currentHeapHandle;
extern BOOL saftyFrameF;
extern u16 strlinecnt;
extern u16 empstrline;
extern int fontcolor;
extern u32 procfunc;
extern WipeState wipeData;
extern PlayerConfig gPlayerConfig[4];
#endif

View file

@ -1,20 +1,164 @@
#include "subchrselDll.h"
#include "common.h"
void fn_1_A0(void) {
//HACK: Force 0.5 and 3.0 double constants to appear in REL
const double _half = 0.5;
const double _three = 3.0;
static void SubchrMain(void);
static u8 cur_direction[4];
static char *player_numstr[4] = {
"PLAYER1",
"PLAYER2",
"PLAYER3",
"PLAYER4"
};
static char *character_str[8] = {
"MARIO",
"LUIGI",
"PEACH",
"YOSHI",
"WARIO",
"DONKEY",
"DAISY",
"WALUIGI"
};
static char *ext_character_str[7] = {
"",
"KOOPA",
"KINOPIO",
"HEIHOH",
"TERESA",
"NOKO2",
"MKOOPA"
};
void ModuleProlog(void)
{
void* sp8 = omInitObjMan(0x32, 0x2000);
Hu3DBGColorSet(0U, 0U, 0U);
fn_8000C760(&fn_1_164, 0x1000, 0x3000, 0, fn_8000CA3C());
fn_800414AC(1, 0, -1);
Hu3DBGColorSet(0, 0, 0);
HuPrcChildCreate(SubchrMain, 4096, 12288, 0, HuPrcCurrentGet());
WipeCreate(1, 0, -1);
}
u16 fn_1_10C(void) {
u16 var_r31;
static u16 GetBtns(void)
{
u16 btns;
var_r31 = lbl_801D3AD0;
if (lbl_1_bss_0 != lbl_801D3AAC) {
var_r31 |= lbl_801D3AAC;
btns = HuPadBtnDown[0];
if (cur_direction[0] != HuPadDStk[0]) {
btns |= HuPadDStk[0];
}
return var_r31;
return btns;
}
// void fn_1_164(void)
static void SubchrMain()
{
int character[4];
int ext_character[4];
int i, cursor_pos;
for(i=0; i<4; i++) {
character[i] = gPlayerConfig[i].character;
ext_character[i] = 0;
cur_direction[i] = 0;
}
cursor_pos = 0;
while(1) {
int y, x;
u16 btns;
fontcolor = 14;
print8(150, 64, 2.0f, "Sub Character Select");
x = 170;
y = 120;
for(i=0; i<4; i++, y += 16) {
fontcolor = 12;
print8(x, y, 2.0f, player_numstr[i]);
if(i == cursor_pos) {
fontcolor = 13;
} else {
fontcolor = 12;
}
if(ext_character[i] != 0) {
print8(x+200, y, 2.0f, ext_character_str[ext_character[i]]);
} else {
print8(x+200, y, 2.0f, character_str[character[i]]);
}
}
if(GetBtns() & 0x1000) {
for(i=0; i<4; i++) {
if(ext_character[i] != 0) {
gPlayerConfig[i]. character = ext_character[i]+7;
}
}
fn_80032A58(30);
WipeCreate(2, 0, -1);
HuPrcSleep(wipeData.duration+1.0f);
fn_80035A0C();
omOvlGotoEx(41, 1, 0, 0);
do {
HuPrcVSleep();
} while(1);
} else {
if(GetBtns() & 0x1) {
do {
ext_character[cursor_pos]--;
if(ext_character[cursor_pos] < 0) {
ext_character[cursor_pos] = 6;
}
for(i=0; i<4; i++) {
if(cursor_pos != i) {
if(ext_character[cursor_pos] == ext_character[i] && ext_character[cursor_pos] != 0) {
break;
}
}
}
} while(i < 4);
}
if(GetBtns() & 0x2) {
do {
ext_character[cursor_pos]++;
if(ext_character[cursor_pos] > 6) {
ext_character[cursor_pos] = 0;
}
for(i=0; i<4; i++) {
if(cursor_pos != i) {
if(ext_character[cursor_pos] == ext_character[i] && ext_character[cursor_pos] != 0) {
break;
}
}
}
} while(i < 4);
}
if(GetBtns() & 0x4) {
cursor_pos++;
}
if(GetBtns() & 0x8) {
cursor_pos--;
}
if(cursor_pos < 0) {
cursor_pos = 3;
}
if(cursor_pos > 3) {
cursor_pos = 0;
}
if(GetBtns() & 0x200) {
fn_80032A58(30);
WipeCreate(2, 0, -1);
HuPrcSleep(wipeData.duration+1.0f);
fn_80035A0C();
omOvlReturnEx(1, 1);
do {
HuPrcVSleep();
} while(1);
} else {
if(cur_direction[0] != HuPadDStk[0]) {
cur_direction[0] = HuPadDStk[0];
}
}
}
HuPrcVSleep();
}
}

View file

@ -1,38 +0,0 @@
#include "common.h"
#include "REL/executor.h"
void fn_8000C760(void*, s32, s32, s32, s32);
s32 fn_8000CA3C();
void fn_800414AC(s16, s16, s16);
extern u8 lbl_1_bss_0;
extern u8 lbl_801D3AAC;
extern u16 lbl_801D3AD0;
typedef struct unkStruct192360 {
char unk_00[0x34];
f32 unk_34;
} unkStruct192360;
s16 fn_8000AFF4(s16, s16, f32, char*, ...); /* extern */
void fn_8000CF0C(s32, f32); /* extern */
void fn_8000CF8C(); /* extern */
void fn_8002EEC0(s32, s16, s32, s32); /* extern */
void fn_8002EF20(s16, s16); /* extern */
void fn_80032A58(s32); /* extern */
void fn_80035A0C(void); /* extern */
void fn_800414AC(s16, s16, s16); /* extern */
extern s32 debugFontColor;
extern u8 lbl_1_bss_0;
extern char *lbl_1_data_20[4];
extern char *lbl_1_data_64[8];
extern char *lbl_1_data_B0[7];
extern char lbl_1_data_CC[20];
extern s16 lbl_8018FC10[];
extern unkStruct192360 lbl_80192360;
extern u8 lbl_801D3AAC;
extern u16 lbl_801D3AD0;
void fn_1_A0(void);
u16 fn_1_10C(void);
void fn_1_164(void);

View file

@ -1,8 +1,6 @@
#include "common.h"
#include "dolphin/os.h"
extern OSHeapHandle currentHeapHandle;
static u32 HeapSizeTbl[5] = { 0x240000, 0x140000, 0xA80000, 0x580000, 0 };
static void *HeapTbl[5];

51
src/game/printfunc.c Normal file
View file

@ -0,0 +1,51 @@
#include "common.h"
#include "dolphin/gx.h"
struct strline_data {
u16 type;
u16 last_idx;
s16 x;
s16 y;
s16 w;
s16 h;
s16 empty_line;
float scale;
char str[80];
GXColor color;
};
static struct strline_data strline[256];
static char pfStrBuf[256];
BOOL saftyFrameF;
u16 strlinecnt;
u16 empstrline;
int fontcolor;
void pfClsScr(void);
void pfInit(void)
{
int i;
fontcolor = 15;
empstrline = 0;
for (i = 0; i < 256; i++) {
strline[i].str[0] = 0;
}
pfClsScr();
}
void pfClsScr(void)
{
int i;
empstrline = 0;
strlinecnt = 0;
for (i = 0; i < 256; i++) {
strline[i].empty_line = i+1;
strline[i].type = 0;
if (strline[i].str[0] != 0) {
strline[i].str[0] = 0;
}
}
}

View file

@ -1,97 +1,356 @@
#include "common.h"
#include "dolphin/os.h"
extern unkStruct145A98 lbl_80145A98[0x100];
extern s32 debugFontColor;
extern s16 lbl_801D3B2C;
extern s16 lbl_801D3B2E;
extern s16 lbl_801D3B3C;
extern unkStruct1D3B44* lbl_801D3B44;
extern int gcsetjmp(jmp_buf *jump);
extern void gclongjmp(jmp_buf *jump, int status);
void fn_8000AEF0(void) {
s32 i;
#define EXEC_NORMAL 0
#define EXEC_SLEEP 1
#define EXEC_CHILDWATCH 2
#define EXEC_KILLED 3
debugFontColor = 0xF;
lbl_801D3B2E = 0;
for (i = 0; i < 0x100; i++) {
lbl_80145A98[i].unk_14 = 0;
}
fn_8000AF54();
static jmp_buf processjmpbuf;
static Process *processtop;
static Process *processcur;
static u16 processcnt;
u32 procfunc;
void HuPrcInit(void)
{
processcnt = 0;
processtop = NULL;
}
void fn_8000AF54(void) {
s32 i;
static void LinkProcess(Process** root, Process* process) {
Process* src_process = *root;
lbl_801D3B2E = 0;
lbl_801D3B2C = 0;
for (i = 0; i < 0x100; i++) {
lbl_80145A98[i].unk_0C = (s16) (i + 1);
lbl_80145A98[i].unk_00 = 0;
if (lbl_80145A98[i].unk_14 != 0) {
lbl_80145A98[i].unk_14 = 0;
if (src_process && (src_process->prio >= process->prio)) {
while (src_process->next && src_process->next->prio >= process->prio) {
src_process = src_process->next;
}
process->next = src_process->next;
process->prev = src_process;
src_process->next = process;
if (process->next) {
process->next->prev = process;
}
} else {
process->next = (*root);
process->prev = NULL;
*root = process;
if (src_process) {
src_process->prev = process;
}
}
}
static void UnlinkProcess(Process **root, Process *process) {
if (process->next) {
process->next->prev = process->prev;
}
if (process->prev) {
process->prev->next = process->next;
}
else {
*root = process->next;
}
}
Process *HuPrcCreate(void (*func)(void), u16 prio, u32 stack_size, s32 extra_size)
{
Process *process;
s32 alloc_size;
void *heap;
if(stack_size == 0) {
stack_size = 2048;
}
alloc_size = HuMemMemoryAllocSizeGet(sizeof(Process))
+HuMemMemoryAllocSizeGet(stack_size)
+HuMemMemoryAllocSizeGet(extra_size);
if(!(heap = HuMemDirectMalloc(0, alloc_size))) {
OSReport("process> malloc error size %d\n", alloc_size);
return NULL;
}
HuMemHeapInit(heap, alloc_size);
process = HuMemMemoryAlloc(heap, sizeof(Process), 0xA5A5A5A5);
process->heap = heap;
process->exec = EXEC_NORMAL;
process->stat = 0;
process->prio = prio;
process->sleep_time = 0;
process->base_sp = ((u32)HuMemMemoryAlloc(heap, stack_size, 0xA5A5A5A5))+stack_size-8;
gcsetjmp(&process->jump);
process->jump.lr = (u32)func;
process->jump.sp = process->base_sp;
process->dtor = NULL;
process->user_data = NULL;
LinkProcess(&processtop, process);
process->child = NULL;
process->parent = NULL;
processcnt++;
return process;
}
void HuPrcChildLink(Process *parent, Process *child)
{
HuPrcChildUnlink(child);
if(parent->child) {
parent->child->first_child = child;
}
child->next_child = parent->child;
child->first_child = NULL;
parent->child = child;
child->parent = parent;
}
void HuPrcChildUnlink(Process *process)
{
if(process->parent) {
if(process->next_child) {
process->next_child->first_child = process->first_child;
}
if(process->first_child) {
process->first_child->next_child = process->next_child;
} else {
process->parent->child = process->next_child;
}
process->parent = NULL;
}
}
Process *HuPrcChildCreate(void (*func)(void), u16 prio, u32 stack_size, s32 extra_size, Process *parent)
{
Process *child = HuPrcCreate(func, prio, stack_size, extra_size);
HuPrcChildLink(parent, child);
return child;
}
void HuPrcChildWatch()
{
Process *curr = HuPrcCurrentGet();
if(curr->child) {
curr->exec = EXEC_CHILDWATCH;
if(!gcsetjmp(&curr->jump)) {
gclongjmp(&processjmpbuf, 1);
}
}
}
void HuPrcInit(void) {
lbl_801D3B3C = 0;
lbl_801D3B44 = NULL;
Process *HuPrcCurrentGet()
{
return processcur;
}
// ...
// HuPrcCall
// HuPrcMemAlloc
// HuPrcMemFree
void HuPrcSetStat(unkStruct1D3B44* arg0, u16 arg1) {
arg0->unk_1E |= arg1;
static int SetKillStatusProcess(Process *process)
{
if(process->exec != EXEC_KILLED) {
HuPrcWakeup(process);
process->exec = EXEC_KILLED;
return 0;
} else {
return -1;
}
}
void HuPrcResetStat(unkStruct1D3B44* arg0, s32 arg1) {
arg0->unk_1E &= ~arg1;
int HuPrcKill(Process *process)
{
if(process == NULL) {
process = HuPrcCurrentGet();
}
HuPrcChildKill(process);
HuPrcChildUnlink(process);
return SetKillStatusProcess(process);
}
void HuPrcAllPause(s32 arg0) {
unkStruct1D3B44* var_r31;
void HuPrcChildKill(Process *process)
{
Process *child = process->child;
while(child) {
if(child->child) {
HuPrcChildKill(child);
}
SetKillStatusProcess(child);
child = child->next_child;
}
process->child = NULL;
}
var_r31 = lbl_801D3B44;
if (arg0 != 0) {
while (var_r31 != NULL) {
if ((var_r31->unk_1E & 4) == 0) {
var_r31->unk_1E |= (u16) 1;
static void gcTerminateProcess(Process *process)
{
if(process->dtor) {
process->dtor();
}
UnlinkProcess(&processtop, process);
processcnt--;
gclongjmp(&processjmpbuf, 2);
}
void HuPrcEnd()
{
Process *process = HuPrcCurrentGet();
HuPrcChildKill(process);
HuPrcChildUnlink(process);
gcTerminateProcess(process);
}
void HuPrcSleep(s32 time)
{
Process *process = HuPrcCurrentGet();
if(time != 0 && process->exec != EXEC_KILLED) {
process->exec = EXEC_SLEEP;
process->sleep_time = time;
}
if(!gcsetjmp(&process->jump)) {
gclongjmp(&processjmpbuf, 1);
}
}
void HuPrcVSleep()
{
Process *process = HuPrcCurrentGet();
if(!gcsetjmp(&process->jump)) {
gclongjmp(&processjmpbuf, 1);
}
}
void HuPrcWakeup(Process *process)
{
process->sleep_time = 0;
}
void HuPrcDestructorSet2(Process *process, void (*func)(void))
{
process->dtor = func;
}
void HuPrcDestructorSet(void (*func)(void))
{
Process *process = HuPrcCurrentGet();
process->dtor = func;
}
void HuPrcCall(int tick)
{
Process *process;
int ret;
processcur = processtop;
ret = gcsetjmp(&processjmpbuf);
while(1) {
switch(ret) {
case 2:
HuMemDirectFree(processcur->heap);
case 1:
if(((u8 *)(processcur->heap))[4] != 165) {
printf("stack overlap error.(process pointer %x)\n", processcur);
while(1);
} else {
processcur = processcur->next;
}
break;
}
process = processcur;
if(!process) {
return;
}
procfunc = process->jump.lr;
if((process->stat & 0x3) && process->exec != EXEC_KILLED) {
ret = 1;
continue;
}
switch(process->exec) {
case EXEC_SLEEP:
if(process->sleep_time > 0) {
process->sleep_time -= tick;
if(process->sleep_time <= 0) {
process->sleep_time = 0;
process->exec = EXEC_NORMAL;
}
}
ret = 1;
break;
case EXEC_CHILDWATCH:
if(process->child) {
ret = 1;
} else {
process->exec = EXEC_NORMAL;
ret = 0;
}
break;
case EXEC_KILLED:
process->jump.lr = (u32)HuPrcEnd;
case EXEC_NORMAL:
gclongjmp(&process->jump, 1);
break;
}
}
}
void *HuPrcMemAlloc(s32 size)
{
Process *process = HuPrcCurrentGet();
return HuMemMemoryAlloc(process->heap, size, 0xA5A5A5A5);
}
void HuPrcMemFree(void *ptr)
{
HuMemMemoryFree(ptr, 0xA5A5A5A5);
}
void HuPrcSetStat(Process *process, u16 value)
{
process->stat |= value;
}
void HuPrcResetStat(Process *process, u16 value)
{
process->stat &= ~value;
}
void HuPrcAllPause(int flag)
{
Process *process = processtop;
if(flag) {
while(process != NULL) {
if(!(process->stat & 0x4)) {
HuPrcSetStat(process, 0x1);
}
var_r31 = var_r31->prev;
process = process->next;
}
return;
}
while (var_r31 != NULL) {
if ((var_r31->unk_1E & 1) != 0) {
var_r31->unk_1E &= -2;
}
var_r31 = var_r31->prev;
}
}
void HuPrcAllUPause(s32 arg0) {
unkStruct1D3B44* var_r31;
var_r31 = lbl_801D3B44;
if (arg0 != 0) {
while (var_r31 != NULL) {
if ((var_r31->unk_1E & 8) == 0) {
var_r31->unk_1E |= (u16) 2;
} else {
while(process != NULL) {
if(process->stat & 0x1) {
HuPrcResetStat(process, 0x1);
}
var_r31 = var_r31->prev;
process = process->next;
}
}
}
void HuPrcAllUPause(int flag)
{
Process *process = processtop;
if(flag) {
while(process != NULL) {
if(!(process->stat & 0x8)) {
HuPrcSetStat(process, 0x2);
}
process = process->next;
}
} else {
while(process != NULL) {
if(process->stat & 0x2) {
HuPrcResetStat(process, 0x2);
}
process = process->next;
}
return;
}
while (var_r31 != NULL) {
if ((var_r31->unk_1E & 2) != 0) {
var_r31->unk_1E &= -3;
}
var_r31 = var_r31->prev;
}
}