diff --git a/config/GMPE01_00/rels/E3setupDLL/symbols.txt b/config/GMPE01_00/rels/E3setupDLL/symbols.txt index 2fe290d7..85cff679 100644 --- a/config/GMPE01_00/rels/E3setupDLL/symbols.txt +++ b/config/GMPE01_00/rels/E3setupDLL/symbols.txt @@ -42,35 +42,36 @@ InitCamera = .text:0x000056A8; // type:function size:0x7C scope:local UpdateCamera = .text:0x00005724; // type:function size:0x12C scope:local _ctors = .ctors:0x00000000; // type:label scope:global data:4byte _dtors = .dtors:0x00000000; // type:label scope:global data:4byte -lbl_2_rodata_10 = .rodata:0x00000010; // type:object size:0x4 data:float -lbl_2_rodata_14 = .rodata:0x00000014; // type:object size:0x4 data:float -lbl_2_rodata_18 = .rodata:0x00000018; // type:object size:0x4 data:float -lbl_2_rodata_1C = .rodata:0x0000001C; // type:object size:0x4 data:float -lbl_2_rodata_20 = .rodata:0x00000020; // type:object size:0x4 data:float -lbl_2_rodata_24 = .rodata:0x00000024; // type:object size:0x4 data:float -lbl_2_rodata_28 = .rodata:0x00000028; // type:object size:0x4 data:float -lbl_2_rodata_2C = .rodata:0x0000002C; // type:object size:0x4 data:float -lbl_2_rodata_30 = .rodata:0x00000030; // type:object size:0x4 data:float -lbl_2_rodata_34 = .rodata:0x00000034; // type:object size:0x4 data:float -lbl_2_rodata_38 = .rodata:0x00000038; // type:object size:0x4 data:float -lbl_2_rodata_3C = .rodata:0x0000003C; // type:object size:0x4 data:float -lbl_2_rodata_40 = .rodata:0x00000040; // type:object size:0x4 data:float -lbl_2_rodata_44 = .rodata:0x00000044; // type:object size:0x4 data:float -lbl_2_rodata_48 = .rodata:0x00000048; // type:object size:0x4 data:float -lbl_2_rodata_4C = .rodata:0x0000004C; // type:object size:0x4 data:float -lbl_2_rodata_50 = .rodata:0x00000050; // type:object size:0x4 data:float -lbl_2_rodata_54 = .rodata:0x00000054; // type:object size:0x4 data:float -lbl_2_rodata_58 = .rodata:0x00000058; // type:object size:0x4 data:float -lbl_2_rodata_5C = .rodata:0x0000005C; // type:object size:0x4 data:float -lbl_2_rodata_60 = .rodata:0x00000060; // type:object size:0x4 data:float -lbl_2_rodata_64 = .rodata:0x00000064; // type:object size:0x4 data:float -lbl_2_rodata_68 = .rodata:0x00000068; // type:object size:0x4 data:float -lbl_2_rodata_6C = .rodata:0x0000006C; // type:object size:0x4 data:float -lbl_2_rodata_70 = .rodata:0x00000070; // type:object size:0x4 data:float -lbl_2_rodata_74 = .rodata:0x00000074; // type:object size:0x4 data:float -lbl_2_rodata_78 = .rodata:0x00000078; // type:object size:0x4 data:float -lbl_2_rodata_7C = .rodata:0x0000007C; // type:object size:0x4 data:float -lbl_2_rodata_80 = .rodata:0x00000080; // type:object size:0x8 data:float +lbl_2_rodata_0 = .rodata:0x00000000; // type:object size:0xA +lbl_2_rodata_10 = .rodata:0x00000010; // type:object size:0x4 scope:local data:float +lbl_2_rodata_14 = .rodata:0x00000014; // type:object size:0x4 scope:local data:float +lbl_2_rodata_18 = .rodata:0x00000018; // type:object size:0x4 scope:local data:float +lbl_2_rodata_1C = .rodata:0x0000001C; // type:object size:0x4 scope:local data:float +lbl_2_rodata_20 = .rodata:0x00000020; // type:object size:0x4 scope:local data:float +lbl_2_rodata_24 = .rodata:0x00000024; // type:object size:0x4 scope:local data:float +lbl_2_rodata_28 = .rodata:0x00000028; // type:object size:0x4 scope:local data:float +lbl_2_rodata_2C = .rodata:0x0000002C; // type:object size:0x4 scope:local data:float +lbl_2_rodata_30 = .rodata:0x00000030; // type:object size:0x4 scope:local data:float +lbl_2_rodata_34 = .rodata:0x00000034; // type:object size:0x4 scope:local data:float +lbl_2_rodata_38 = .rodata:0x00000038; // type:object size:0x4 scope:local data:float +lbl_2_rodata_3C = .rodata:0x0000003C; // type:object size:0x4 scope:local data:float +lbl_2_rodata_40 = .rodata:0x00000040; // type:object size:0x4 scope:local data:float +lbl_2_rodata_44 = .rodata:0x00000044; // type:object size:0x4 scope:local data:float +lbl_2_rodata_48 = .rodata:0x00000048; // type:object size:0x4 scope:local data:float +lbl_2_rodata_4C = .rodata:0x0000004C; // type:object size:0x4 scope:local data:float +lbl_2_rodata_50 = .rodata:0x00000050; // type:object size:0x4 scope:local data:float +lbl_2_rodata_54 = .rodata:0x00000054; // type:object size:0x4 scope:local data:float +lbl_2_rodata_58 = .rodata:0x00000058; // type:object size:0x4 scope:local data:float +lbl_2_rodata_5C = .rodata:0x0000005C; // type:object size:0x4 scope:local data:float +lbl_2_rodata_60 = .rodata:0x00000060; // type:object size:0x4 scope:local data:float +lbl_2_rodata_64 = .rodata:0x00000064; // type:object size:0x4 scope:local data:float +lbl_2_rodata_68 = .rodata:0x00000068; // type:object size:0x4 scope:local data:float +lbl_2_rodata_6C = .rodata:0x0000006C; // type:object size:0x4 scope:local data:float +lbl_2_rodata_70 = .rodata:0x00000070; // type:object size:0x4 scope:local data:float +lbl_2_rodata_74 = .rodata:0x00000074; // type:object size:0x4 scope:local data:float +lbl_2_rodata_78 = .rodata:0x00000078; // type:object size:0x4 scope:local data:float +lbl_2_rodata_7C = .rodata:0x0000007C; // type:object size:0x4 scope:local data:float +lbl_2_rodata_80 = .rodata:0x00000080; // type:object size:0x8 scope:local data:float lbl_2_rodata_88 = .rodata:0x00000088; // type:object size:0x4 scope:local data:float lbl_2_rodata_8C = .rodata:0x0000008C; // type:object size:0x4 scope:local data:float lbl_2_rodata_90 = .rodata:0x00000090; // type:object size:0x4 scope:local data:float @@ -112,29 +113,29 @@ lbl_2_rodata_120 = .rodata:0x00000120; // type:object size:0x4 scope:local data: lbl_2_rodata_124 = .rodata:0x00000124; // type:object size:0x4 scope:local data:float lbl_2_rodata_128 = .rodata:0x00000128; // type:object size:0x4 scope:local data:float lbl_2_rodata_12C = .rodata:0x0000012C; // type:object size:0x4 scope:local data:float -lbl_2_data_0 = .data:0x00000000; // type:object size:0x24 -lbl_2_data_24 = .data:0x00000024; // type:object size:0x11 data:string +lbl_2_data_0 = .data:0x00000000; // type:object size:0x24 data:float +lbl_2_data_24 = .data:0x00000024; // type:object size:0x11 scope:local data:string lbl_2_data_36 = .data:0x00000036; // type:object size:0x8 mgOvlTbl = .data:0x0000003E; // type:object size:0x1A scope:local mgIdTbl = .data:0x00000058; // type:object size:0x1C scope:local mgNameTbl = .data:0x00000074; // type:object size:0x34 scope:local -lbl_2_data_A8 = .data:0x000000A8; // type:object size:0x21 -lbl_2_data_C9 = .data:0x000000C9; // type:object size:0x16 -lbl_2_data_DF = .data:0x000000DF; // type:object size:0x16 -lbl_2_data_F5 = .data:0x000000F5; // type:object size:0x16 -lbl_2_data_10B = .data:0x0000010B; // type:object size:0xD -lbl_2_data_118 = .data:0x00000118; // type:object size:0x16 -lbl_2_data_12E = .data:0x0000012E; // type:object size:0xD -lbl_2_data_13B = .data:0x0000013B; // type:object size:0x16 -lbl_2_data_151 = .data:0x00000151; // type:object size:0x16 -lbl_2_data_167 = .data:0x00000167; // type:object size:0x16 -lbl_2_data_17D = .data:0x0000017D; // type:object size:0x16 -lbl_2_data_193 = .data:0x00000193; // type:object size:0x16 -lbl_2_data_1A9 = .data:0x000001A9; // type:object size:0x17 +lbl_2_data_A8 = .data:0x000000A8; // type:object size:0x21 data:string +lbl_2_data_C9 = .data:0x000000C9; // type:object size:0x16 data:string +lbl_2_data_DF = .data:0x000000DF; // type:object size:0x16 data:string +lbl_2_data_F5 = .data:0x000000F5; // type:object size:0x16 data:string +lbl_2_data_10B = .data:0x0000010B; // type:object size:0xD data:string +lbl_2_data_118 = .data:0x00000118; // type:object size:0x16 data:string +lbl_2_data_12E = .data:0x0000012E; // type:object size:0xD data:string +lbl_2_data_13B = .data:0x0000013B; // type:object size:0x16 data:string +lbl_2_data_151 = .data:0x00000151; // type:object size:0x16 data:string +lbl_2_data_167 = .data:0x00000167; // type:object size:0x16 data:string +lbl_2_data_17D = .data:0x0000017D; // type:object size:0x16 data:string +lbl_2_data_193 = .data:0x00000193; // type:object size:0x16 data:string +lbl_2_data_1A9 = .data:0x000001A9; // type:object size:0x17 data:string mgNameTestTbl = .data:0x000001C0; // type:object size:0x34 scope:local -cursorYOfsTbl = .data:0x000001F4; // type:object size:0x14 scope:local +cursorYOfsTbl = .data:0x000001F4; // type:object size:0x14 scope:local data:float mgPicTbl = .data:0x00000208; // type:object size:0x34 scope:local -startText = .data:0x0000023C; // type:object size:0x14 scope:local +startText = .data:0x0000023C; // type:object size:0x14 scope:local data:string shadowPos = .data:0x00000250; // type:object size:0xC scope:local shadowTarget = .data:0x0000025C; // type:object size:0xC scope:local shadowUp = .data:0x00000268; // type:object size:0xC scope:local @@ -158,13 +159,15 @@ camViewTbl = .data:0x00000418; // type:object size:0x60 scope:local data:float lbl_2_data_478 = .data:0x00000478; // type:object size:0x24 data:float lbl_2_data_49C = .data:0x0000049C; // type:object size:0x24 data:float lbl_2_data_4C0 = .data:0x000004C0; // type:object size:0x10 +lbl_2_bss_0 = .bss:0x00000000; // type:object size:0xA data:2byte lbl_2_bss_A = .bss:0x0000000A; // type:object size:0x2 data:2byte lbl_2_bss_C = .bss:0x0000000C; // type:object size:0x2 data:2byte +lbl_2_bss_E = .bss:0x0000000E; // type:object size:0x2 data:2byte lbl_2_bss_10 = .bss:0x00000010; // type:object size:0x2 data:2byte lbl_2_bss_14 = .bss:0x00000014; // type:object size:0x4 data:4byte mgPicObj = .bss:0x00000018; // type:object size:0x4 scope:local data:4byte mgSelectObj = .bss:0x0000001C; // type:object size:0x4 scope:local data:4byte -mgInterface = .bss:0x00000020; // type:object size:0x4 scope:local data:4byte +mgInterfaceObj = .bss:0x00000020; // type:object size:0x4 scope:local data:4byte mgDefault = .bss:0x00000024; // type:object size:0x2 scope:local data:2byte repBtn = .bss:0x00000028; // type:object size:0x2 scope:local data:2byte lbl_2_bss_2A = .bss:0x0000002A; // type:object size:0xA data:2byte diff --git a/configure.py b/configure.py index 76d38062..864c2ff0 100644 --- a/configure.py +++ b/configure.py @@ -781,7 +781,7 @@ config.libs = [ ), Rel('E3setupDLL', objects = { - Object(NonMatching, "REL/E3setupDLL/mgselect.c"), + Object(Matching, "REL/E3setupDLL/mgselect.c"), Object(Matching, "REL/executor.c"), Object(Matching, "REL/E3setupDLL/main.c"), } diff --git a/include/REL/E3SetupDLL.h b/include/REL/E3SetupDLL.h index ef58102c..651af661 100644 --- a/include/REL/E3SetupDLL.h +++ b/include/REL/E3SetupDLL.h @@ -1,6 +1,7 @@ #ifndef E3SETUPDLL_H #define E3SETUPDLL_H +#include "game/animdata.h" #include "game/object.h" #include "game/pad.h" @@ -11,13 +12,86 @@ typedef struct e3pad { u16 unk6; } E3Pad; +typedef struct mgInterface { + /* 0x00 */ AnimData *unk00[2]; + /* 0x08 */ s32 pad; + /* 0x0C */ s32 pad2; + /* 0x10 */ s32 pad3; + /* 0x14 */ s32 pad4; + /* 0x18 */ s32 pad5; + /* 0x1C */ s16 group; + /* 0x1E */ s16 group2; + /* 0x20 */ s32 pad6; + /* 0x24 */ s32 pad7; + /* 0x28 */ s32 pad8; + /* 0x2C */ s16 unk2C; + /* 0x2E */ s32 pad9; + /* the struct is 0x34 big */ +} mgInterface; + +typedef struct mgPic { + /* 0x00 */ AnimData *unk00[2]; + /* 0x08 */ s32 pad; + /* 0x0C */ s32 pad2; + /* 0x10 */ s32 pad3; + /* 0x14 */ s32 pad4; + /* 0x18 */ s32 pad5; + /* 0x1C */ s16 pad6; + /* 0x1E */ s16 pad7; + /* 0x20 */ s32 pad8; + /* 0x24 */ s32 pad9; + /* 0x28 */ s32 pad10; + /* 0x2C */ s16 unk2C; + /* 0x2E */ s32 pad11; + /* 0x32 */ s32 pad12; + /* 0x36 */ s32 pad13; + /* 0x3A */ s32 pad14; + /* 0x40 */ s16 unk40; + /* 0x44 */ s32 pad15; + /* 0x48 */ s32 pad16; + /* 0x4C */ s32 unk4C; + /* 0x50 */ s32 pad18; + /* the struct is 0x54 big */ +} mgPic; + +typedef struct mgSelect { + /* 0x00 */ AnimData *unk00[4]; + /* 0x10 */ s32 pad3; + /* 0x14 */ s32 pad4; + /* 0x18 */ s32 pad5; + /* 0x1C */ s16 unk1C; + /* 0x1E */ s16 unk1E; + /* 0x20 */ s16 unk20; + /* 0x22 */ s16 pad20; + /* 0x24 */ s32 pad9; + /* 0x28 */ s32 pad10; + /* 0x2C */ s16 unk2C; + /* 0x2E */ s16 unk2E[4]; + /* 0x36 */ s16 pad13; + /* 0x38 */ s16 unk38[4]; + /* 0x40 */ s16 pad15; + /* 0x42 */ s16 unk42; + /* 0x44 */ s16 unk44; + /* 0x46 */ s16 unk46; + /* 0x48 */ s32 pad17; + /* 0x4C */ s32 pad18; + /* 0x50 */ s32 pad19; + /* the struct is 0x54 big */ +} mgSelect; + extern E3Pad e3PadData[4]; extern s16 e3PadCtrl; +extern s16 e3ConfigPlayerCnt; extern s16 e3ConfigPlayerF; extern s32 e3ExitEnableF; extern OverlayID e3NextOvl; extern s32 e3NextEvent; extern u32 e3ExitMode; +extern float e3CameraFov; +extern omObjData *e3MenuMainObj; +extern omObjData *e3ViewObj; +extern omObjData *e3OvlWatchObj; +extern omObjData *e3BGObj; void E3MainInit(void); void E3MGSelectInit(void); @@ -27,4 +101,4 @@ void E3OvlWatchInit(omObjData *object); void E3BGCreate(omObjData *object); void E3LightInit(void); -#endif \ No newline at end of file +#endif diff --git a/src/REL/E3setupDLL/mgselect.c b/src/REL/E3setupDLL/mgselect.c index e69de29b..adfc9082 100644 --- a/src/REL/E3setupDLL/mgselect.c +++ b/src/REL/E3setupDLL/mgselect.c @@ -0,0 +1,501 @@ +#include "ext_math.h" +#include "game/gamework_data.h" +#include "game/hsfman.h" +#include "game/init.h" +#include "game/objsub.h" +#include "game/sprite.h" +#include "game/window.h" +#include "rel_sqrt_consts.h" + +#include "REL/E3SetupDLL.h" + +static s16 mgDefault; +static omObjData *mgInterfaceObj; +static omObjData *mgSelectObj; +static omObjData *mgPicObj; + +s32 lbl_2_bss_14; +s16 lbl_2_bss_10; +s16 lbl_2_bss_E; +s16 lbl_2_bss_C; +s16 lbl_2_bss_A; +static s16 lbl_2_bss_0[5]; + +float lbl_2_data_0[] = { 0, 12000, 0, 0, 0, 0, 0, 0, -1 }; + +static void StartMGSelect(omObjData *object); +static void UpdatePad(omObjData *object); +static void CreateMGSelect(omObjData *object); +static void CreateMGPic(omObjData *object); +static void UpdateMGInterface(omObjData *object); +static void CreateMGInterface(omObjData *object); + +void E3MGSelectInit() +{ + s32 var_r29; + s32 var_r30; + Process *var_r31; + + for (var_r29 = 0, var_r30 = 0; var_r29 < 4; var_r29++) { + if (HuPadStatGet(var_r29) == 0) { + var_r30 += 1; + } + } + e3ConfigPlayerCnt = var_r30; + if (var_r30 <= 0) { + OSReport("No pad detected\n"); + var_r30 += 1; + } + mgDefault = 0; + HuSysVWaitSet(1); + var_r31 = omInitObjMan(0x50, 0x2000); + HuWinInit(1); + CRot.x = -4.0f; + CRot.y = 0.0f; + CRot.z = 0.0f; + Center.x = 0.0f; + Center.y = 160.0f; + Center.z = 0.0f; + CZoom = 1960.0; + e3CameraFov = 40.0f; + Hu3DCameraCreate(1); + Hu3DCameraPerspectiveSet(1, e3CameraFov, 100.0f, 25000.0f, 4.0f / 3.0f); + e3ViewObj = omAddObjEx(var_r31, 32730, 0, 0, -1, omOutView); + e3OvlWatchObj = omAddObjEx(var_r31, 200, 0, 0, -1, E3OvlWatchInit); + e3MenuMainObj = omAddObjEx(var_r31, 10, 0, 0, -1, StartMGSelect); + e3BGObj = omAddObjEx(var_r31, 0x14, 0, 0, -1, E3BGCreate); + mgInterfaceObj = omAddObjEx(var_r31, 20, 0, 0, -1, CreateMGInterface); + mgSelectObj = omAddObjEx(var_r31, 30, 0, 0, -1, CreateMGSelect); + mgPicObj = omAddObjEx(var_r31, 31, 0, 0, -1, CreateMGPic); + mgPicObj->work[0] = mgDefault; + E3LightInit(); + WipeCreate(1, 0, -1); +} + +s16 lbl_2_data_36[] = { 0x0023, 0x0026, 0x0029, 0x002C }; + +static s16 mgOvlTbl[] = { + 11, + 12, + 15, + 18, + 20, + 23, + 26, + 27, + 33, + 34, + 39, + 44, + 46, +}; + +static s16 mgIdTbl[] = { 403, 404, 407, 410, 412, 415, 418, 419, 425, 426, 431, 436, 438, 0 }; + +static s32 mgNameTbl[] = { + 0x00170003, + 0x00170004, + 0x00170007, + 0x0017000A, + 0x0017000C, + 0x0017000F, + 0x00170012, + 0x00170013, + 0x00170019, + 0x0017001A, + 0x0017001F, + 0x00170024, + 0x00170026, +}; + +char lbl_2_data_A8[] = "\013TEST MINIGAME NAME01\n test"; +char lbl_2_data_C9[] = "\013TEST MINIGAME NAME02"; +char lbl_2_data_DF[] = "\013TEST MINIGAME NAME03"; +char lbl_2_data_F5[] = "\013TEST MINIGAME NAME04"; +char lbl_2_data_10B[] = "\013TEST NAME05"; +char lbl_2_data_118[] = "\013TEST MINIGAME NAME06"; +char lbl_2_data_12E[] = "\013TEST NAME07"; +char lbl_2_data_13B[] = "\013TEST MINIGAME NAME08"; +char lbl_2_data_151[] = "\013TEST MINIGAME NAME09"; +char lbl_2_data_167[] = "\013TEST MINIGAME NAME10"; +char lbl_2_data_17D[] = "\013TEST MINIGAME NAME11"; +char lbl_2_data_193[] = "\013TEST MINIGAME NAME12"; +char lbl_2_data_1A9[] = "\013TEST MINIGAME NAME13\000"; + +static char *mgNameTestTbl[] = { + lbl_2_data_A8, + lbl_2_data_C9, + lbl_2_data_DF, + lbl_2_data_F5, + lbl_2_data_10B, + lbl_2_data_118, + lbl_2_data_12E, + lbl_2_data_13B, + lbl_2_data_151, + lbl_2_data_167, + lbl_2_data_17D, + lbl_2_data_193, + lbl_2_data_1A9, +}; + +static float cursorYOfsTbl[] = { -100.0f, -50.0f, 0.0f, 50.0f, 100.0f }; + +static s32 mgPicTbl[] = { 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52 }; + +static char startText[] = "\013\016\r PRESS START\000\000\000\000"; + +static void StartMGSelect(omObjData *object) +{ + HuAudSeqPlay(0x2B); + lbl_2_bss_14 = 0; + lbl_2_bss_10 = -1; + lbl_2_bss_C = 0x1E; + lbl_2_bss_A = 0; + object->func = UpdatePad; + worstVcount = 0; + object->work[0] = 0; + object->work[1] = 0; +} + +static void UpdatePad(omObjData *object) +{ + s32 i; + s32 players; + + if (e3ExitEnableF == 0) { + for (i = 0, players = 0; i < 4; i++) { + E3PadUpdate(i, &e3PadData[i]); + if (!e3PadData[i].enable) { + players++; + } + } + e3ConfigPlayerCnt = players; + } +} + +static void UpdateMGSelect(omObjData *object) +{ + mgSelect *var_r31; + s32 var_r30; + u32 var_r28; + s16 var_r27; + s16 var_r26; + s16 var_r25; + s16 var_r24; + u16 var_r23; + s16 var_r22; + s32 var_r21; + float sp8[2]; + + var_r31 = object->data; + var_r23 = e3PadData[e3PadCtrl].btnDown; + if (object->work[3] != 0) { + if ((var_r23 & 0x1100) != 0) { + HuAudFXPlay(1); + mgDefault = var_r31->unk44; + var_r21 = mgIdTbl[var_r31->unk44]; + GWMGAvailSet(var_r21); + GWSystem.mg_next = var_r21 - 401; + e3NextOvl = 3; + e3NextEvent = 0; + e3ExitMode = 2; + e3ExitEnableF = 1; + var_r28 = mgOvlTbl[var_r31->unk44]; + + for (var_r30 = 0; var_r30 < 50; var_r30++) { + if (var_r28 == mgInfoTbl[var_r30].ovl) { + break; + } + } + if (var_r30 >= 50) { + e3ExitMode = 0; + e3NextOvl = 0; + }; + switch (mgInfoTbl[var_r30].type) { + case 0: + case 3: + case 4: + case 5: + case 6: + for (var_r30 = 0; var_r30 < 4; var_r30++) { + GWPlayerCfg[var_r30].group = var_r30; + } + break; + case 1: + var_r28 = frand(); + var_r28 &= 3; + for (var_r30 = 0; var_r30 < 4; var_r30++) { + if (var_r28 == var_r30) { + GWPlayerCfg[var_r30].group = 0; + } else { + GWPlayerCfg[var_r30].group = 1; + } + } + break; + case 2: + for (var_r30 = 0; var_r30 < 2; var_r30++) { + GWPlayerCfg[var_r30].group = 0; + } + for (var_r30 = 2; var_r30 < 4; var_r30++) { + GWPlayerCfg[var_r30].group = 1; + } + break; + } + object->work[3] = 0; + return; + } + if ((var_r23 & 0x200) != 0) { + HuAudFXPlay(3); + e3ExitMode = 0; + e3NextOvl = 0; + e3NextEvent = 0; + e3ExitEnableF = 1; + object->work[3] = 0; + return; + } + if (object->work[3] != 0) { + if ((var_r23 & 8) != 0) { + HuAudFXPlay(0); + var_r31->unk44--; + if (var_r31->unk44 < 0) { + var_r31->unk44 = 0xC; + } + } else if ((var_r23 & 4) != 0) { + HuAudFXPlay(0); + var_r31->unk44++; + if (var_r31->unk44 >= 13) { + var_r31->unk44 = 0; + } + } + if (var_r31->unk46 != var_r31->unk44) { + mgPicObj->work[0] = var_r31->unk44; + var_r27 = var_r31->unk44 - var_r31->unk46; + if ((var_r27 > 1) || (var_r27 < -1)) { + if (var_r27 < 0) { + var_r27 = 1; + } else { + var_r27 = -1; + } + } + var_r25 = var_r31->unk42 + var_r27; + if ((var_r25 < 0) || (var_r25 >= 5)) { + for (var_r30 = 0; var_r30 < 5; var_r30++) { + var_r22 = var_r31->unk2E[var_r30]; + var_r26 = var_r31->unk38[var_r30]; + var_r24 = var_r26 - var_r27; + if ((var_r24 < 0) || (var_r24 >= 5)) { + var_r28 = mgNameTbl[var_r31->unk44]; + HuWinMesSizeCancelCRSet(1); + HuWinMesMaxSizeGet(1, sp8, var_r28); + HuWinCenterPosSet(var_r22, (296.0f - sp8[0]) / -2.0f, (68.0f - sp8[1]) / -2.0f); + HuWinMesSet(var_r22, var_r28); + if (var_r24 < 0) { + var_r26 = 4; + } else { + var_r26 = 0; + } + } else { + var_r26 = var_r24; + } + HuWinPosSet(var_r22, 36.0f, 237.0f + cursorYOfsTbl[var_r26]); + var_r31->unk38[var_r30] = var_r26; + } + } else { + var_r31->unk42 = var_r25; + HuSprPosSet(var_r31->unk1C, 1, 0.0f, cursorYOfsTbl[var_r25]); + } + var_r31->unk46 = var_r31->unk44; + } + } + } +} + +static void CreateMGSelect(omObjData *object) +{ + mgSelect *temp_r31; + s16 temp_r30; + s16 temp_r29; + s32 var_r28; + s16 var_r26; + s16 index2; + u32 temp_r22; + s32 temp_r21; + AnimData *temp_r25; + AnimData *temp_r23; + float sp8[2]; + + omSetStatBit(object, OM_STAT_MODEL_PAUSED); + object->data = HuMemDirectMallocNum(HEAP_SYSTEM, 0x48, MEMORY_DEFAULT_NUM); + temp_r31 = object->data; + index2 = 0; + temp_r30 = HuSprGrpCreate(3); + temp_r31->unk1C = temp_r30; + HuSprGrpPosSet(temp_r30, 174.0f, 271.0f); + temp_r25 = HuSprAnimRead(HuDataReadNum(0x21, MEMORY_DEFAULT_NUM)); + temp_r31->unk00[index2] = temp_r25; + temp_r29 = HuSprCreate(temp_r25, 0x7540, 0); + HuSprGrpMemberSet(temp_r30, index2, temp_r29); + index2++; + temp_r25 = HuSprAnimRead(HuDataReadNum(0x27, MEMORY_DEFAULT_NUM)); + temp_r31->unk00[index2] = temp_r25; + temp_r29 = HuSprCreate(temp_r25, 0x64, 0); + HuSprGrpMemberSet(temp_r30, index2, temp_r29); + HuSprScaleSet(temp_r30, index2, 1.1f, 1.0f); + HuSprTPLvlSet(temp_r30, index2, 0.5f); + temp_r31->unk42 = 0; + HuSprPosSet(temp_r30, index2, 0.0f, cursorYOfsTbl[temp_r31->unk42]); + index2++; + temp_r25 = HuSprAnimRead(HuDataReadNum(0x35, MEMORY_DEFAULT_NUM)); + temp_r31->unk00[index2++] = temp_r25; + temp_r23 = HuSprAnimRead(HuDataReadNum(0x36, MEMORY_DEFAULT_NUM)); + temp_r31->unk00[index2++] = temp_r23; + temp_r30 = HuSprGrpCreate(2); + temp_r31->unk1E = temp_r30; + HuSprGrpPosSet(temp_r30, 174.0f, 128.0f); + temp_r29 = HuSprCreate(temp_r25, 4, 0); + HuSprGrpMemberSet(temp_r30, 0, temp_r29); + temp_r29 = HuSprCreate(temp_r23, 6, 0); + HuSprGrpMemberSet(temp_r30, 1, temp_r29); + HuSprTPLvlSet(temp_r30, 1, 0.7f); + HuSprPosSet(temp_r30, 1, 0.0f, -4.0f); + temp_r30 = HuSprGrpCreate(2); + temp_r31->unk20 = temp_r30; + HuSprGrpPosSet(temp_r30, 174.0f, 414.0f); + temp_r29 = HuSprCreate(temp_r25, 4, 1); + HuSprGrpMemberSet(temp_r30, 0, temp_r29); + temp_r29 = HuSprCreate(temp_r23, 6, 1); + HuSprGrpMemberSet(temp_r30, 1, temp_r29); + HuSprTPLvlSet(temp_r30, 1, 0.7f); + HuSprPosSet(temp_r30, 1, 0.0f, -4.0f); + + temp_r21 = GWSystem.mg_next + 401; + var_r26 = temp_r21; + for (var_r28 = 0; var_r28 < 13;) { + if (var_r26 != mgIdTbl[var_r28]) { + var_r28++; + } else { + break; + } + } + if (var_r28 >= 13) { + var_r28 = 0; + } + mgDefault = var_r28; + var_r26 = mgDefault; + mgPicObj->work[0] = var_r26; + temp_r31->unk44 = var_r26; + temp_r31->unk46 = var_r26; + + for (var_r28 = 0; var_r28 < 5;) { + if (var_r26 >= 13) { + var_r26 = 0; + } + temp_r29 = HuWinCreate(36.0f, 237.0f + cursorYOfsTbl[var_r28], 0x128, 0x44, 0x4E20); + temp_r31->unk2E[var_r28] = temp_r29; + temp_r31->unk38[var_r28] = var_r28; + HuWinBGTPLvlSet(temp_r29, 0.0f); + HuWinMesSpeedSet(temp_r29, 0); + temp_r22 = mgNameTbl[var_r26]; + HuWinAttrSet(temp_r29, 0x100); + HuWinMesSizeCancelCRSet(1); + HuWinMesMaxSizeGet(1, sp8, temp_r22); + HuWinCenterPosSet(temp_r29, (296.0f - sp8[0]) / -2.0f, (68.0f - sp8[1]) / -2.0f); + HuWinMesSet(temp_r29, temp_r22); + var_r28++; + var_r26++; + } + object->work[3] = 1; + object->func = &UpdateMGSelect; +} + +static void UpdateMGPic(omObjData *object) +{ + mgPic *temp_r30 = (mgPic *)object->data; + s16 temp_r29; + + if (object->work[1] != object->work[0]) { + temp_r29 = temp_r30->unk40; + HuSprAttrSet(temp_r29, object->work[1], 4); + HuSprAttrReset(temp_r29, object->work[0], 4); + object->work[1] = object->work[0]; + } +} + +static void CreateMGPic(omObjData *object) +{ + mgPic *temp_r28; + AnimData *temp_r3_2; + s16 temp_r3; + s32 var_r30; + s32 index; + s16 index2; + s16 group; + + omSetStatBit(object, OM_STAT_MODEL_PAUSED); + object->data = HuMemDirectMallocNum(HEAP_SYSTEM, sizeof(mgPic), MEMORY_DEFAULT_NUM); + temp_r28 = object->data; + index2 = 0; + temp_r3 = HuSprGrpCreate(14); + temp_r28->unk40 = temp_r3; + HuSprGrpPosSet(temp_r3, 444.0f, 228.0f); + + for (var_r30 = 0; var_r30 < 13; var_r30++) { + temp_r3_2 = HuSprAnimRead(HuDataReadNum(mgPicTbl[var_r30], MEMORY_DEFAULT_NUM)); + temp_r28->unk00[var_r30] = temp_r3_2; + group = HuSprCreate(temp_r3_2, 0x2710, 0); + HuSprGrpMemberSet(temp_r3, var_r30, group); + HuSprScaleSet(temp_r3, var_r30, 0.6f, 0.6f); + HuSprAttrSet(temp_r3, var_r30, 4); + } + index2 = var_r30; + temp_r3_2 = HuSprAnimRead(HuDataReadNum(0x22, MEMORY_DEFAULT_NUM)); + temp_r28->unk00[index2] = temp_r3_2; + group = HuSprCreate(temp_r3_2, 0x7540, 0); + HuSprGrpMemberSet(temp_r3, index2, group); + HuSprTPLvlSet(temp_r3, index2, 0.7f); + index2++; + object->work[1] = object->work[0]; + HuSprAttrReset(temp_r3, object->work[1], 4); + object->func = &UpdateMGPic; +} + +static void UpdateMGInterface(omObjData *object) { void *sp8 = object->data; } + +static void CreateMGInterface(omObjData *object) +{ + mgInterface *unkStruct; + s16 index; + s16 group; + s16 index2; + AnimData *temp_r3_2; + float sp8[2]; + + omSetStatBit(object, OM_STAT_MODEL_PAUSED); + object->data = HuMemDirectMallocNum(HEAP_SYSTEM, sizeof(mgInterface), MEMORY_DEFAULT_NUM); + unkStruct = object->data; + index2 = 0; + group = HuSprGrpCreate(1); + unkStruct->group = group; + HuSprGrpPosSet(group, 288.0f, 64.0f); + temp_r3_2 = HuSprAnimRead(HuDataReadNum(0x24, MEMORY_DEFAULT_NUM)); + unkStruct->unk00[index2] = temp_r3_2; + index = HuSprCreate(temp_r3_2, 0x2710, 0); + HuSprGrpMemberSet(group, 0, index); + index2++; + group = HuSprGrpCreate(1); + unkStruct->group2 = group; + HuSprGrpPosSet(group, 444.0f, 384.0f); + temp_r3_2 = HuSprAnimRead(HuDataReadNum(0x23, MEMORY_DEFAULT_NUM)); + unkStruct->unk00[index2] = temp_r3_2; + index = HuSprCreate(temp_r3_2, 0x271A, 0); + HuSprGrpMemberSet(group, 0, index); + index2++; + HuWinMesMaxSizeGet(1, sp8, &startText); + index = HuWinCreate(340.0f, 362.0f, sp8[0], sp8[1], 0); + unkStruct->unk2C = index; + HuWinMesColSet(index, 0); + HuWinBGTPLvlSet(index, 0.0f); + HuWinMesSpeedSet(index, 0); + HuWinMesSet(index, MAKE_MESSID_PTR(startText)); + object->func = UpdateMGInterface; +}