From ed2fb89d88134815e27e9e985389bde1b5fda9fe Mon Sep 17 00:00:00 2001 From: Banjo Kazooie Date: Mon, 26 Aug 2024 10:46:28 -0500 Subject: [PATCH] gcdialog_update matched --- README.md | 3 +- progress/progress_core2.svg | 6 +- progress/progress_total.svg | 6 +- src/core2/code_87E30.c | 946 +++++++++++++++++++----------------- 4 files changed, 502 insertions(+), 459 deletions(-) diff --git a/README.md b/README.md index 29cce5d8..68cfa99f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# banjo (99.3923%) +# banjo (99.5858%) @@ -27,7 +27,6 @@ Be sure to check scratch "family" for any progress that may not be reflected her | ------------------ | --------------- | ---------------------------------------- | ------ | ----- | | core2/code_12F30.c | func_80299EC0 | [Ar62G](https://decomp.me/scratch/Ar62G) | 77.65% | | core2/code_7AF80.c | func_80307948 | [zd8KD](https://decomp.me/scratch/zd8KD) | 85.40% | -| core2/code_87E30.c | gcdialog_update | [cPns0](https://decomp.me/scratch/cPns0) | 92.23% | | core2/code_B9770.c | func_80340BE4 | [FXyYS](https://decomp.me/scratch/FXyYS) | 65.91% | spline function | core2/code_B9770.c | func_803411B0 | [rHkDu](https://decomp.me/scratch/rHkDu) | 87.70% | spline function diff --git a/progress/progress_core2.svg b/progress/progress_core2.svg index 673f0ed1..d08e45ea 100644 --- a/progress/progress_core2.svg +++ b/progress/progress_core2.svg @@ -9,7 +9,7 @@ - + @@ -17,7 +17,7 @@ core2 - 98.9409% - 98.9409% + 99.2781% + 99.2781% \ No newline at end of file diff --git a/progress/progress_total.svg b/progress/progress_total.svg index 6f6e28b0..7e705082 100644 --- a/progress/progress_total.svg +++ b/progress/progress_total.svg @@ -9,7 +9,7 @@ - + @@ -17,7 +17,7 @@ Banjo-Kazooie (us.v10) - 99.3923% - 99.3923% + 99.5858% + 99.5858% \ No newline at end of file diff --git a/src/core2/code_87E30.c b/src/core2/code_87E30.c index 4d48289f..739569a6 100644 --- a/src/core2/code_87E30.c +++ b/src/core2/code_87E30.c @@ -9,6 +9,7 @@ extern int func_803114B0(void); extern void gczoombox_open(gczoombox_t *); extern void gczoombox_minimize(gczoombox_t *); extern void gczoombox_close(gczoombox_t *); +extern void gczoombox_update(gczoombox_t *); extern bool func_803188B4(gczoombox_t *); extern char *dialogBin_get(enum asset_e text_id); @@ -26,24 +27,48 @@ struct { struct15s unk11A[2]; gczoombox_t *zoombox[2]; s16 unk124[2]; - u32 unk128_31:8; - u32 state:8; - u32 unk128_15:8; - u32 active_zoombox:1; //active_zoombox_index - u32 unk128_6:1; - u32 unk128_5:1; - u32 unk128_4:1; - u32 unk128_3:1; - u32 pad128_2:2; - u32 unk128_0:1; - u32 unk12C_31:2; - u32 unk12C_29:2; - u32 unk12C_27:2; - u32 unk12C_25:2; - s32 unk12C_23:8; - u32 unk12C_15:4; - u32 unk12C_11:4; - u32 pad12C_7:8; + union{ + struct { + u8 unk128_31; + u8 state; + u8 unk128_15; + u8 active_zoombox:1; //active_zoombox_index + u8 unk128_6:1; + u8 unk128_5:1; + u8 unk128_4:1; + u8 unk128_3:1; + u8 pad128_2:2; + u8 unk128_0:1; + u8 unk12C_31:2; + u8 unk12C_29:2; + u8 unk12C_27:2; + u8 unk12C_25:2; + s8 unk12C_23:8; + u8 unk12C_15:4; + u8 unk12C_11:4; + u8 pad12C_7:8; + } u8; + struct { + u32 unk128_31:8; + u32 state:8; + u32 unk128_15:8; + u32 active_zoombox:1; //active_zoombox_index + u32 unk128_6:1; + u32 unk128_5:1; + u32 unk128_4:1; + u32 unk128_3:1; + u32 pad128_2:2; + u32 unk128_0:1; + u32 unk12C_31:2; + u32 unk12C_29:2; + u32 unk12C_27:2; + u32 unk12C_25:2; + s32 unk12C_23:8; + u32 unk12C_15:4; + u32 unk12C_11:4; + u32 pad12C_7:8; + }; + }; s16 unk130; s8 unk132; u8 pad133[0x1]; @@ -53,7 +78,7 @@ struct { void (* unk140)(ActorMarker *, s32, s32); s32 (* unk144)(ActorMarker *, s32, s32); struct14s unk148[4]; -} D_80382E20; +} g_Dialog; char D_80382FF8[0x18]; /* .code */ @@ -75,51 +100,51 @@ void gcdialog_init(void) { s32 i; struct14s *i_ptr; - D_80382E20.dialog_bin_ptr = 0; + g_Dialog.dialog_bin_ptr = 0; for( i = 0; i < 2; i++){ - D_80382E20.string_list[i] = NULL; - D_80382E20.string_count[i] = 0; - D_80382E20.zoombox[i] = NULL; - D_80382E20.string_index[i] = NULL; - D_80382E20.string_cmd[i] = -1; - D_80382E20.string[i] = 0; - D_80382E20.unk11A[i].unk0_7 = 0; - D_80382E20.unk11A[i].unk0_5 = 0; + g_Dialog.string_list[i] = NULL; + g_Dialog.string_count[i] = 0; + g_Dialog.zoombox[i] = NULL; + g_Dialog.string_index[i] = NULL; + g_Dialog.string_cmd[i] = -1; + g_Dialog.string[i] = 0; + g_Dialog.unk11A[i].unk0_7 = 0; + g_Dialog.unk11A[i].unk0_5 = 0; } for(i = 0; i < 4; i++){ - D_80382E20.unk148[i].unk0 = -1; - D_80382E20.unk148[i].unk2 = 0; - D_80382E20.unk148[i].unk10 = NULL; - D_80382E20.unk148[i].unk14 = 0; - D_80382E20.unk148[i].unk18 = NULL; - D_80382E20.unk148[i].unk1C = NULL; - D_80382E20.unk148[i].unk20 = 0; - D_80382E20.unk148[i].unk4[0] = D_80382E20.unk148[i].unk4[1] = D_80382E20.unk148[i].unk4[2] = 0; + g_Dialog.unk148[i].unk0 = -1; + g_Dialog.unk148[i].unk2 = 0; + g_Dialog.unk148[i].unk10 = NULL; + g_Dialog.unk148[i].unk14 = 0; + g_Dialog.unk148[i].unk18 = NULL; + g_Dialog.unk148[i].unk1C = NULL; + g_Dialog.unk148[i].unk20 = 0; + g_Dialog.unk148[i].unk4[0] = g_Dialog.unk148[i].unk4[1] = g_Dialog.unk148[i].unk4[2] = 0; } - D_80382E20.state = 0; - D_80382E20.unk128_31 = D_80382E20.unk128_5 = FALSE; - D_80382E20.unk12C_31 = D_80382E20.unk12C_29 = D_80382E20.unk12C_27 = D_80382E20.unk12C_25 = 0; - D_80382E20.unk128_15 = D_80382E20.active_zoombox = FALSE; - D_80382E20.unk128_6 = TRUE; - D_80382E20.unk12C_23 = -1; - D_80382E20.unk12C_15 = D_80382E20.unk12C_11 = 0; - D_80382E20.unk130 = (s16) -1; - D_80382E20.caller = NULL; - D_80382E20.unk13C = NULL; - D_80382E20.unk140 = NULL; - D_80382E20.unk144 = 0; - D_80382E20.unk132 = 0xC; - D_80382E20.unk128_3 = TRUE; + g_Dialog.state = 0; + g_Dialog.unk128_31 = g_Dialog.unk128_5 = FALSE; + g_Dialog.unk12C_31 = g_Dialog.unk12C_29 = g_Dialog.unk12C_27 = g_Dialog.unk12C_25 = 0; + g_Dialog.unk128_15 = g_Dialog.active_zoombox = FALSE; + g_Dialog.unk128_6 = TRUE; + g_Dialog.unk12C_23 = -1; + g_Dialog.unk12C_15 = g_Dialog.unk12C_11 = 0; + g_Dialog.unk130 = (s16) -1; + g_Dialog.caller = NULL; + g_Dialog.unk13C = NULL; + g_Dialog.unk140 = NULL; + g_Dialog.unk144 = 0; + g_Dialog.unk132 = 0xC; + g_Dialog.unk128_3 = TRUE; } static void _gcdialog_freeZoomboxes(void){ s32 i; for(i =0; i < 2; i++){ - gczoombox_free(D_80382E20.zoombox[i]); - D_80382E20.zoombox[i] = NULL; + gczoombox_free(g_Dialog.zoombox[i]); + g_Dialog.zoombox[i] = NULL; } } @@ -127,34 +152,34 @@ void func_8030F078(void){ s32 i; s32 j; for(i = 0; i <2; i++){ - for(j =0; j < D_80382E20.string_count[i]; j++){ - D_80382E20.string_list[i][j].str = NULL; + for(j =0; j < g_Dialog.string_count[i]; j++){ + g_Dialog.string_list[i][j].str = NULL; } - D_80382E20.string_count[i] = 0; - free(D_80382E20.string_list[i]); - D_80382E20.string_list[i] = NULL; + g_Dialog.string_count[i] = 0; + free(g_Dialog.string_list[i]); + g_Dialog.string_list[i] = NULL; } - if(D_80382E20.unk130 != -1){ - dialogBin_release(D_80382E20.unk130); + if(g_Dialog.unk130 != -1){ + dialogBin_release(g_Dialog.unk130); } - D_80382E20.dialog_bin_ptr = NULL; + g_Dialog.dialog_bin_ptr = NULL; } void func_8030F130(void){ func_8030F078(); - if(D_80382E20.zoombox[1] != NULL && !D_80382E20.unk11A[1].unk0_7){ + if(g_Dialog.zoombox[1] != NULL && !g_Dialog.unk11A[1].unk0_7){ func_80347A14(1); } - if(!D_80382E20.unk11A[0].unk0_7 && !D_80382E20.unk11A[1].unk0_7){ + if(!g_Dialog.unk11A[0].unk0_7 && !g_Dialog.unk11A[1].unk0_7){ _gcdialog_freeZoomboxes(); } - D_80382E20.unk130 = -1; - D_80382E20.unk128_15 = 0; - D_80382E20.unk128_31 = 0; - D_80382E20.caller = NULL; - D_80382E20.unk13C = NULL; - D_80382E20.unk140 = NULL; - D_80382E20.unk144 = NULL; + g_Dialog.unk130 = -1; + g_Dialog.unk128_15 = 0; + g_Dialog.unk128_31 = 0; + g_Dialog.caller = NULL; + g_Dialog.unk13C = NULL; + g_Dialog.unk140 = NULL; + g_Dialog.unk144 = NULL; } void func_8030F1D0(void){ @@ -163,7 +188,7 @@ void func_8030F1D0(void){ } func_803114D0(); func_8030F130(); - D_80382E20.state = 0; + g_Dialog.state = 0; } void func_8030F218(char *next_state, char *arg1, char *arg2, bool arg3, bool arg4) { @@ -198,17 +223,17 @@ void func_8030F218(char *next_state, char *arg1, char *arg2, bool arg3, bool arg } void func_8030F338(void){ - if(D_80382E20.unk13C != NULL){ - if(D_80382E20.caller == NULL){ - D_80382E20.unk13C(D_80382E20.caller, D_80382E20.unk130, D_80382E20.unk12C_23); + if(g_Dialog.unk13C != NULL){ + if(g_Dialog.caller == NULL){ + g_Dialog.unk13C(g_Dialog.caller, g_Dialog.unk130, g_Dialog.unk12C_23); }else{ - if(func_8030EDC0(D_80382E20.caller, D_80382E20.unk138)){ - D_80382E20.unk13C(D_80382E20.caller, D_80382E20.unk130, D_80382E20.unk12C_23); + if(func_8030EDC0(g_Dialog.caller, g_Dialog.unk138)){ + g_Dialog.unk13C(g_Dialog.caller, g_Dialog.unk130, g_Dialog.unk12C_23); } } } - if(D_80382E20.unk128_31 & 0x8){ - if((!func_802E4A08() && !func_803203FC(UNKFLAGS1_1F_IN_CHARACTER_PARADE)) || !D_80382E20.unk128_3){ + if(g_Dialog.unk128_31 & 0x8){ + if((!func_802E4A08() && !func_803203FC(UNKFLAGS1_1F_IN_CHARACTER_PARADE)) || !g_Dialog.unk128_3){ func_8028F918(0); } }//L8030F3E8 @@ -219,7 +244,7 @@ void func_8030F338(void){ void gcdialog_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx){ s32 i; for(i = 0; i<2; i++){ - gczoombox_draw(D_80382E20.zoombox[i], gfx, mtx, vtx); + gczoombox_draw(g_Dialog.zoombox[i], gfx, mtx, vtx); } } @@ -229,43 +254,43 @@ void gcdialog_setState(s32 next_state){ s32 v0 = 6; if(v0); - if(D_80382E20.state != v0 || next_state != v0){ + if(g_Dialog.state != v0 || next_state != v0){ switch(next_state){ case 1: for(i = 0; i < 2; i++){ - if(D_80382E20.zoombox[i] != NULL && D_80382E20.unk11A[i].unk0_7 == 0) - gczoombox_open(D_80382E20.zoombox[i]); + if(g_Dialog.zoombox[i] != NULL && g_Dialog.unk11A[i].unk0_7 == 0) + gczoombox_open(g_Dialog.zoombox[i]); } break; case 5: for(i =0; i < 2; i++){ - if(D_80382E20.zoombox[i] != NULL && D_80382E20.unk11A[i].unk0_7 == 0){ - gczoombox_minimize(D_80382E20.zoombox[i]); - gczoombox_close(D_80382E20.zoombox[i]); + if(g_Dialog.zoombox[i] != NULL && g_Dialog.unk11A[i].unk0_7 == 0){ + gczoombox_minimize(g_Dialog.zoombox[i]); + gczoombox_close(g_Dialog.zoombox[i]); } } break; case 6: for(i = 0; i< 2; i++){//L8030F59C - for(j = D_80382E20.string_index[i]; D_80382E20.string_list[i][j].cmd < -4 || D_80382E20.string_list[i][j].cmd >= 0; j++){ - if(D_80382E20.string_list[i][j].cmd == -7 && D_80382E20.unk140){ - if(D_80382E20.caller == NULL){ - D_80382E20.unk140(D_80382E20.caller, D_80382E20.unk130, *D_80382E20.string_list[i][j].str); + for(j = g_Dialog.string_index[i]; g_Dialog.string_list[i][j].cmd < -4 || g_Dialog.string_list[i][j].cmd >= 0; j++){ + if(g_Dialog.string_list[i][j].cmd == -7 && g_Dialog.unk140){ + if(g_Dialog.caller == NULL){ + g_Dialog.unk140(g_Dialog.caller, g_Dialog.unk130, *g_Dialog.string_list[i][j].str); }else{ - if(func_8030EDC0(D_80382E20.caller, D_80382E20.unk138)){ - D_80382E20.unk140(D_80382E20.caller, D_80382E20.unk130, *D_80382E20.string_list[i][j].str); + if(func_8030EDC0(g_Dialog.caller, g_Dialog.unk138)){ + g_Dialog.unk140(g_Dialog.caller, g_Dialog.unk130, *g_Dialog.string_list[i][j].str); } } } } } - D_80382E20.unk12C_25 = 0; + g_Dialog.unk12C_25 = 0; for(i=0; i< 2; i++){ - D_80382E20.unk11A[i].unk0_7 = 0; - if(D_80382E20.zoombox[i] != NULL){ - D_80382E20.unk12C_25 += (u8)func_803188B4(D_80382E20.zoombox[i]); + g_Dialog.unk11A[i].unk0_7 = 0; + if(g_Dialog.zoombox[i] != NULL){ + g_Dialog.unk12C_25 += (u8)func_803188B4(g_Dialog.zoombox[i]); } } break; @@ -277,16 +302,16 @@ void gcdialog_setState(s32 next_state){ case 8: func_8030F338(); for(i=0; i<2; i++){ - if(D_80382E20.unk11A[i].unk0_7 == 0){ - gczoombox_free(D_80382E20.zoombox[i]); - D_80382E20.zoombox[i] = NULL; + if(g_Dialog.unk11A[i].unk0_7 == 0){ + gczoombox_free(g_Dialog.zoombox[i]); + g_Dialog.zoombox[i] = NULL; } } break; default: break; } - D_80382E20.state = next_state; + g_Dialog.state = next_state; } } @@ -297,7 +322,7 @@ void func_8030F754(enum talk_pic_e portrait_id, s32 arg1){ switch(arg1){ case 1: //L8030F790 - D_80382E20.unk12C_31++; + g_Dialog.unk12C_31++; break; case 3: //L8030F7BC @@ -305,271 +330,290 @@ void func_8030F754(enum talk_pic_e portrait_id, s32 arg1){ break; case 4: //L8030F7CC - if(D_80382E20.state == 6){ - D_80382E20.unk12C_25--; - if(D_80382E20.unk12C_25 == 0){ - temp_a0 = ((D_80382E20.unk11A[0].unk0_7) ? 1 : 0); - temp_v0 = ((D_80382E20.unk11A[1].unk0_7) ? 1 : 0); + if(g_Dialog.state == 6){ + g_Dialog.unk12C_25--; + if(g_Dialog.unk12C_25 == 0){ + temp_a0 = ((g_Dialog.unk11A[0].unk0_7) ? 1 : 0); + temp_v0 = ((g_Dialog.unk11A[1].unk0_7) ? 1 : 0); gcdialog_setState((temp_v0 + temp_a0) ? 8 : 5); }//L8030F980 break; } - temp_v0 = ((D_80382E20.unk11A[0].unk0_7) ? 1 : 0) + ((D_80382E20.unk11A[1].unk0_7) ? 1 : 0); - if(temp_v0 > (s32)D_80382E20.unk12C_29){ - D_80382E20.unk12C_29++; - if(D_80382E20.unk128_15 == D_80382E20.unk12C_29 + D_80382E20.unk12C_27){ + temp_v0 = ((g_Dialog.unk11A[0].unk0_7) ? 1 : 0) + ((g_Dialog.unk11A[1].unk0_7) ? 1 : 0); + if(temp_v0 > (s32)g_Dialog.unk12C_29){ + g_Dialog.unk12C_29++; + if(g_Dialog.unk128_15 == g_Dialog.unk12C_29 + g_Dialog.unk12C_27){ gcdialog_setState(8); } } break; case 6: //L8030F8FC - D_80382E20.unk12C_27++; - if(D_80382E20.unk12C_27 == D_80382E20.unk128_15){ + g_Dialog.unk12C_27++; + if(g_Dialog.unk12C_27 == g_Dialog.unk128_15){ gcdialog_setState(7); }//L8030F964 - if(D_80382E20.unk128_15 == D_80382E20.unk12C_29 + D_80382E20.unk12C_27){ + if(g_Dialog.unk128_15 == g_Dialog.unk12C_29 + g_Dialog.unk12C_27){ gcdialog_setState(8); } break; }//L8030F984 } -#ifndef NONMATCHING -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_87E30/gcdialog_update.s") -#else +#define CMD(i) (g_Dialog.string_list[g_Dialog.u8.active_zoombox] + i) +#define CMD2(i) (&g_Dialog.string_list[g_Dialog.u8.active_zoombox][i]) + void gcdialog_update(void) { - s32 spA8; s32 i; - s32 sp90[6]; - bool temp_v1_2; - s32 sp84[2]; - s32 sp80; + s32 spA8; + s32 controller_face_buttons[6]; + s32 controller_side_buttons[3]; + s32 ret; s32 sp7C; + s32 padding[4]; char *sp4C[8]; - s32 var_v0_6; - s32 var_a3; - s32 var_v0_2; - sp80 = -1; - if (D_80382E20.unk128_31 & 0x80) { - func_8024E5A8(0, sp90); - func_8024E640(0, sp84); + ret = -1; + + if (g_Dialog.u8.unk128_31 & 0x80) { + func_8024E5A8(0, controller_face_buttons); + func_8024E640(0, controller_side_buttons); } else { - func_8024E55C(0, sp90); - func_8024E60C(0, sp84); + func_8024E55C(0, controller_face_buttons); + func_8024E60C(0, controller_side_buttons); } - switch (D_80382E20.state) { /* switch 1 */ - case 1: /* switch 1 */ - var_a3 = 0;\ - for(i = 0; i < 2; i++){ - if(D_80382E20.zoombox[i] == NULL){ - var_a3++; + + switch (g_Dialog.state) { + case 1: + for(spA8 = 0, i = 0; i < 2; i++){ + if(g_Dialog.zoombox[i] == NULL){ + spA8++; + } + } + if (spA8 == 2) { + gcdialog_setState(7); + } else if (g_Dialog.u8.unk12C_31 == g_Dialog.u8.unk128_15) { + g_Dialog.u8.unk12C_31 = 0; + gcdialog_setState(2); + } + break; + + case 2: + if (g_Dialog.zoombox[g_Dialog.u8.active_zoombox] == NULL || func_80318BEC(g_Dialog.zoombox[g_Dialog.u8.active_zoombox]) || g_Dialog.unk11A[g_Dialog.u8.active_zoombox].unk0_5) { + g_Dialog.u8.active_zoombox ^= 1; + } else { + g_Dialog.string_cmd[g_Dialog.u8.active_zoombox] = CMD(g_Dialog.string_index[g_Dialog.u8.active_zoombox])->cmd; + g_Dialog.string[g_Dialog.u8.active_zoombox] = CMD(g_Dialog.string_index[g_Dialog.u8.active_zoombox])->str; + + switch (g_Dialog.string_cmd[g_Dialog.u8.active_zoombox]) { + case -2: + if (g_Dialog.string_index[g_Dialog.u8.active_zoombox] == 0) { + g_Dialog.u8.unk12C_29++; } - }; - if (var_a3 == 2) { - gcdialog_setState(7); - } else if (D_80382E20.unk128_15 == D_80382E20.unk12C_31) { - D_80382E20.unk12C_31 = 0; - gcdialog_setState(2); - } - break; + gczoombox_minimize(g_Dialog.zoombox[g_Dialog.u8.active_zoombox]); + g_Dialog.unk11A[g_Dialog.u8.active_zoombox].unk0_7 = 1; + g_Dialog.unk11A[g_Dialog.u8.active_zoombox].unk0_5 = 1; + g_Dialog.u8.active_zoombox ^= 1; + g_Dialog.unk128_6 = TRUE; + break; - case 2: /* switch 1 */ - if ((D_80382E20.zoombox[D_80382E20.active_zoombox] == NULL) || func_80318BEC(D_80382E20.zoombox[D_80382E20.active_zoombox]) || (D_80382E20.unk11A[D_80382E20.active_zoombox].unk0_5 != 0)) { - D_80382E20.active_zoombox ^= 1; - } else { - D_80382E20.string_cmd[D_80382E20.active_zoombox] = D_80382E20.string_list[D_80382E20.active_zoombox][D_80382E20.string_index[D_80382E20.active_zoombox]].cmd; - D_80382E20.string[D_80382E20.active_zoombox] = D_80382E20.string_list[D_80382E20.active_zoombox][D_80382E20.string_index[D_80382E20.active_zoombox]].str; - switch (D_80382E20.string_cmd[D_80382E20.active_zoombox]) { /* switch 2 */ - case -2: /* switch 2 */ - if (D_80382E20.string_index[D_80382E20.active_zoombox] == 0) { - D_80382E20.unk12C_29++; - } - gczoombox_minimize(D_80382E20.zoombox[D_80382E20.active_zoombox]); - D_80382E20.unk11A[D_80382E20.active_zoombox].unk0_7 = 1; - D_80382E20.unk11A[D_80382E20.active_zoombox].unk0_5 = 1; - D_80382E20.active_zoombox ^= 1; - D_80382E20.unk128_6 = TRUE; - break; + case -1: // Choice + g_Dialog.unk11A[g_Dialog.u8.active_zoombox].unk0_7 = 2; + gcdialog_setState(4); + break; - case -1: /* switch 2 */ - D_80382E20.unk11A[D_80382E20.active_zoombox].unk0_7 = 2; - gcdialog_setState(4); - break; + case -4: // Close + gczoombox_minimize(g_Dialog.zoombox[g_Dialog.u8.active_zoombox]); + gczoombox_close(g_Dialog.zoombox[g_Dialog.u8.active_zoombox]); + g_Dialog.unk11A[g_Dialog.u8.active_zoombox].unk0_7 = 0; + g_Dialog.unk11A[g_Dialog.u8.active_zoombox].unk0_5 = 1; + g_Dialog.u8.active_zoombox ^= 1; + g_Dialog.unk128_6 = TRUE; + break; - case -4: /* switch 2 */ - gczoombox_minimize(D_80382E20.zoombox[D_80382E20.active_zoombox]); - gczoombox_close(D_80382E20.zoombox[D_80382E20.active_zoombox]); - D_80382E20.unk11A[D_80382E20.active_zoombox].unk0_7 = 0; - D_80382E20.unk11A[D_80382E20.active_zoombox].unk0_5 = 1; - D_80382E20.active_zoombox ^= 1; - D_80382E20.unk128_6 = TRUE; - break; - - case -7: /* switch 2 */ - if (D_80382E20.unk140 != NULL) { - if (D_80382E20.caller == NULL) { - D_80382E20.unk140(D_80382E20.caller, D_80382E20.unk130, *D_80382E20.string[D_80382E20.active_zoombox]); - } else if (func_8030EDC0(D_80382E20.caller, D_80382E20.unk138)) { - D_80382E20.unk140(D_80382E20.caller, D_80382E20.unk130, *D_80382E20.string[D_80382E20.active_zoombox]); - } - } - D_80382E20.string_index[D_80382E20.active_zoombox]++; - break; - - case -9: /* switch 2 */ - case -8: /* switch 2 */ - do { - D_80382E20.string_index[D_80382E20.active_zoombox]++; - D_80382E20.string_cmd[D_80382E20.active_zoombox] = D_80382E20.string_list[D_80382E20.active_zoombox][D_80382E20.string_index[D_80382E20.active_zoombox]].cmd; - } while (D_80382E20.string_cmd[D_80382E20.active_zoombox] == -8 || D_80382E20.string_cmd[D_80382E20.active_zoombox] == -9); - break; - - case -6: /* switch 2 */ - for(var_v0_2 = D_80382E20.string_index[D_80382E20.active_zoombox]; - D_80382E20.string_list[D_80382E20.active_zoombox][var_v0_2].cmd < -4; - var_v0_2++){ - } - - if (D_80382E20.string_list[D_80382E20.active_zoombox][var_v0_2].cmd >= 0) { - func_803189C4(D_80382E20.zoombox[D_80382E20.active_zoombox], D_80382E20.string_list[D_80382E20.active_zoombox][var_v0_2].cmd + 0xC); - } - if (D_80382E20.string_index[D_80382E20.active_zoombox]) { - gczoombox_minimize(D_80382E20.zoombox[D_80382E20.active_zoombox]); - } - if ((D_80382E20.string_index[D_80382E20.active_zoombox] == 0) && (D_80382E20.unk11A[D_80382E20.active_zoombox].unk0_7 == 2)) { - gczoombox_minimize(D_80382E20.zoombox[D_80382E20.active_zoombox]); - } - D_80382E20.unk11A[D_80382E20.active_zoombox].unk0_7 = 0; - D_80382E20.string_index[D_80382E20.active_zoombox]++; - D_80382E20.active_zoombox ^= 1; - D_80382E20.unk128_6 = TRUE; - break; - - case -5: /* switch 2 */ - gczoombox_minimize(D_80382E20.zoombox[D_80382E20.active_zoombox]); - D_80382E20.unk11A[D_80382E20.active_zoombox].unk0_7 = 0; - D_80382E20.string_index[D_80382E20.active_zoombox]++; - D_80382E20.active_zoombox ^= 1; - D_80382E20.unk128_6 = TRUE; - break; - - case -3: /* switch 2 */ - D_80382E20.unk11A[D_80382E20.active_zoombox].unk0_7 = 0; - gcdialog_setState(4); - break; - - default: /* switch 2 */ - if (!func_80316ED4(D_80382E20.string_list[D_80382E20.active_zoombox][D_80382E20.string_index[D_80382E20.active_zoombox]].str)) { - D_80382E20.string_index[D_80382E20.active_zoombox]++; - } else { - if(D_80382E20.string_list[D_80382E20.active_zoombox][D_80382E20.string_index[D_80382E20.active_zoombox] + 1].cmd == -8){ - if (D_80382E20.unk144 != NULL) { - sp7C = 1; - - if (D_80382E20.caller == NULL) { - sp80 = D_80382E20.unk144(D_80382E20.caller, D_80382E20.unk130, D_80382E20.string_index[D_80382E20.active_zoombox]); - } - else if (func_8030EDC0(D_80382E20.caller, D_80382E20.unk138)) { - sp80 = D_80382E20.unk144(D_80382E20.caller, D_80382E20.unk130, D_80382E20.string_index[D_80382E20.active_zoombox]); - } - - if (sp80 < 0) { - sp80 = -1 - sp80; - sp7C = 0; - } - if((sp80 >= 0) && ((D_80382E20.string_list[D_80382E20.active_zoombox][D_80382E20.string_index[D_80382E20.active_zoombox] + sp80 + 1].cmd == -8))) { - strlen(D_80382E20.string_list[D_80382E20.active_zoombox][D_80382E20.string_index[D_80382E20.active_zoombox] + sp80 + 1].str); - strlen(D_80382E20.string_list[D_80382E20.active_zoombox][D_80382E20.string_index[D_80382E20.active_zoombox]].str); - func_8030F218(D_80382E20.output, D_80382E20.string_list[D_80382E20.active_zoombox][D_80382E20.string_index[D_80382E20.active_zoombox]].str, D_80382E20.string_list[D_80382E20.active_zoombox][D_80382E20.string_index[D_80382E20.active_zoombox] + sp80 + 1].str, func_8031B604(D_80382E20.string_list[D_80382E20.active_zoombox][D_80382E20.string_index[D_80382E20.active_zoombox]].str), sp7C); - } - else{ - sp80 = -1; - } - } - } else if(D_80382E20.string_list[D_80382E20.active_zoombox][D_80382E20.string_index[D_80382E20.active_zoombox] + 1].cmd == -9){ - if (D_80382E20.unk144 != NULL) { - D_80382FF8[0] = '\0'; - if (D_80382E20.caller == 0) { - sp80 = D_80382E20.unk144(D_80382E20.caller, D_80382E20.unk130, D_80382E20.string_index[D_80382E20.active_zoombox]); - } - else if (func_8030EDC0(D_80382E20.caller, D_80382E20.unk138)) { - sp80 = D_80382E20.unk144(D_80382E20.caller, D_80382E20.unk130, D_80382E20.string_index[D_80382E20.active_zoombox]); - } - strIToA(D_80382FF8, sp80); - strlen(D_80382FF8); - strlen(D_80382E20.string_list[D_80382E20.active_zoombox][D_80382E20.string_index[D_80382E20.active_zoombox]].str); - func_8030F218(D_80382E20.output, D_80382E20.string_list[D_80382E20.active_zoombox][D_80382E20.string_index[D_80382E20.active_zoombox]].str, &D_80382FF8, func_8031B604(D_80382E20.string_list[D_80382E20.active_zoombox][D_80382E20.string_index[D_80382E20.active_zoombox]].str), 0); - } - } - if (func_803189C4(D_80382E20.zoombox[D_80382E20.active_zoombox], D_80382E20.string_cmd[D_80382E20.active_zoombox] + 0xC)) { - gczoombox_minimize(D_80382E20.zoombox[D_80382E20.active_zoombox]); - D_80382E20.unk128_6 = TRUE; - } - if (D_80382E20.unk128_6) { - gczoombox_maximize(D_80382E20.zoombox[D_80382E20.active_zoombox]); - D_80382E20.unk128_6 = FALSE; - } - if (sp80 == -1) { - for(spA8 = D_80382E20.string_index[D_80382E20.active_zoombox]; - ((D_80382E20.string_list[D_80382E20.active_zoombox][spA8].cmd == D_80382E20.string_cmd[D_80382E20.active_zoombox]) && ((spA8 * 0) < 8)); - spA8++ - ){ - sp4C[spA8 - D_80382E20.string_index[D_80382E20.active_zoombox]] = D_80382E20.string_list[D_80382E20.active_zoombox][spA8].str; - } - func_80318284(D_80382E20.zoombox[D_80382E20.active_zoombox], spA8 - D_80382E20.string_index[D_80382E20.active_zoombox], sp4C); - D_80382E20.string_index[D_80382E20.active_zoombox] = spA8; - } else { - func_803183A4(D_80382E20.zoombox[D_80382E20.active_zoombox], D_80382E20.output); - D_80382E20.string_index[D_80382E20.active_zoombox]++; - } - gcdialog_setState(3); - } - break; - } - } - break; - case 3: /* switch 1 */ - temp_v1_2 = D_80382E20.unk128_31 & 0x80; - if (D_80382E20.unk128_0 && (sp90[FACE_BUTTON(BUTTON_B)] == 1)) { - gcdialog_setState(6); - } - else{ - if (!temp_v1_2) { - var_v0_6 = (temp_v1_2) ? func_8024E5E8(0, 4) : func_8024E5E8(0, 3); - if ((var_v0_6 ^ 1) == 0) { - gcdialog_setState(6); + case -7: // Trigger + if (g_Dialog.unk140 != NULL) { + if (g_Dialog.caller == NULL) { + g_Dialog.unk140(g_Dialog.caller, g_Dialog.unk130, *g_Dialog.string[g_Dialog.u8.active_zoombox]); + } else if (func_8030EDC0(g_Dialog.caller, g_Dialog.unk138)) { + g_Dialog.unk140(g_Dialog.caller, g_Dialog.unk130, *g_Dialog.string[g_Dialog.u8.active_zoombox]); } } - } - break; + g_Dialog.string_index[g_Dialog.u8.active_zoombox]++; + break; - case 4: /* switch 1 */ - if (sp90[FACE_BUTTON(BUTTON_A)] == 1) { - D_80382E20.unk12C_23 = 1; - } else if (sp90[FACE_BUTTON(BUTTON_B)] == 1) { - D_80382E20.unk12C_23 = 0; - } - if (D_80382E20.unk12C_23 != -1) { - // var_a0 = 5; - gcdialog_setState((D_80382E20.unk11A[D_80382E20.active_zoombox].unk0_7) ? 8 : 5); - } - break; + case -9: // Substitute integer + case -8: // Conditional text + do { + g_Dialog.string_index[g_Dialog.u8.active_zoombox]++; + g_Dialog.string_cmd[g_Dialog.u8.active_zoombox] = CMD(g_Dialog.string_index[g_Dialog.u8.active_zoombox])->cmd; + } while (g_Dialog.string_cmd[g_Dialog.u8.active_zoombox] == -8 || g_Dialog.string_cmd[g_Dialog.u8.active_zoombox] == -9); + break; - case 7: /* switch 1 */ - case 8: /* switch 1 */ - gcdialog_setState(0); + case -6: // Conditional minimize + for(spA8 = g_Dialog.string_index[g_Dialog.u8.active_zoombox]; CMD2(spA8)->cmd < -4; spA8++); + + if (CMD2(spA8)->cmd >= 0) { + func_803189C4(g_Dialog.zoombox[g_Dialog.u8.active_zoombox], CMD2(spA8)->cmd + 0xC); + } + if (g_Dialog.string_index[g_Dialog.u8.active_zoombox]) { + gczoombox_minimize(g_Dialog.zoombox[g_Dialog.u8.active_zoombox]); + } + if (!g_Dialog.string_index[g_Dialog.u8.active_zoombox] && g_Dialog.unk11A[g_Dialog.u8.active_zoombox].unk0_7 == 2) { + gczoombox_minimize(g_Dialog.zoombox[g_Dialog.u8.active_zoombox]); + } + g_Dialog.unk11A[g_Dialog.u8.active_zoombox].unk0_7 = 0; + g_Dialog.string_index[g_Dialog.u8.active_zoombox]++; + g_Dialog.u8.active_zoombox ^= 1; + g_Dialog.unk128_6 = TRUE; + break; + + case -5: + gczoombox_minimize(g_Dialog.zoombox[g_Dialog.u8.active_zoombox]); + g_Dialog.unk11A[g_Dialog.u8.active_zoombox].unk0_7 = 0; + g_Dialog.string_index[g_Dialog.u8.active_zoombox]++; + g_Dialog.u8.active_zoombox ^= 1; + g_Dialog.unk128_6 = TRUE; + break; + + case -3: + g_Dialog.unk11A[g_Dialog.u8.active_zoombox].unk0_7 = 0; + gcdialog_setState(4); + break; + + default: + if (!func_80316ED4(CMD(g_Dialog.string_index[g_Dialog.u8.active_zoombox])->str)) { + g_Dialog.string_index[g_Dialog.u8.active_zoombox]++; + } else { + if (CMD(g_Dialog.string_index[g_Dialog.u8.active_zoombox] + 1)->cmd == -8) { + // Conditional text - use callback to determine if text should be shown + if (g_Dialog.unk144 != NULL) { + sp7C = 1; + + if (g_Dialog.caller == NULL) { + ret = g_Dialog.unk144(g_Dialog.caller, g_Dialog.unk130, g_Dialog.string_index[g_Dialog.u8.active_zoombox]); + } else if (func_8030EDC0(g_Dialog.caller, g_Dialog.unk138)) { + ret = g_Dialog.unk144(g_Dialog.caller, g_Dialog.unk130, g_Dialog.string_index[g_Dialog.u8.active_zoombox]); + } + + if (ret < 0) { + ret = -1 - ret; + sp7C = 0; + } + + if(ret >= 0 && CMD(g_Dialog.string_index[g_Dialog.u8.active_zoombox] + ret + 1)->cmd == -8) { + strlen(CMD(g_Dialog.string_index[g_Dialog.u8.active_zoombox] + ret + 1)->str); + strlen(CMD(g_Dialog.string_index[g_Dialog.u8.active_zoombox])->str); + + func_8030F218( + g_Dialog.output, + CMD(g_Dialog.string_index[g_Dialog.u8.active_zoombox])->str, + CMD(g_Dialog.string_index[g_Dialog.u8.active_zoombox] + ret + 1)->str, + func_8031B604(CMD(g_Dialog.string_index[g_Dialog.u8.active_zoombox])->str), + sp7C + ); + } else { + ret = -1; + } + } + } else if(CMD(g_Dialog.string_index[g_Dialog.u8.active_zoombox] + 1)->cmd == -9){ + // Integer substitution - use callback to determine integer value + // (used for player's note count in some messages) + if (g_Dialog.unk144 != NULL) { + // static char D_80382FF8[24]; + + D_80382FF8[0] = '\0'; + + if (g_Dialog.caller == NULL) { + ret = g_Dialog.unk144(g_Dialog.caller, g_Dialog.unk130, g_Dialog.string_index[g_Dialog.u8.active_zoombox]); + } else if (func_8030EDC0(g_Dialog.caller, g_Dialog.unk138)) { + ret = g_Dialog.unk144(g_Dialog.caller, g_Dialog.unk130, g_Dialog.string_index[g_Dialog.u8.active_zoombox]); + } + + strIToA(D_80382FF8, ret); + strlen(D_80382FF8); + strlen(CMD(g_Dialog.string_index[g_Dialog.u8.active_zoombox])->str); + + func_8030F218( + g_Dialog.output, + CMD(g_Dialog.string_index[g_Dialog.u8.active_zoombox])->str, + D_80382FF8, + func_8031B604(CMD(g_Dialog.string_index[g_Dialog.u8.active_zoombox])->str), + 0 + ); + } + } + + if (func_803189C4(g_Dialog.zoombox[g_Dialog.u8.active_zoombox], g_Dialog.string_cmd[g_Dialog.u8.active_zoombox] + 12)) { + gczoombox_minimize(g_Dialog.zoombox[g_Dialog.u8.active_zoombox]); + g_Dialog.unk128_6 = TRUE; + } + + if (g_Dialog.unk128_6) { + gczoombox_maximize(g_Dialog.zoombox[g_Dialog.u8.active_zoombox]); + g_Dialog.unk128_6 = FALSE; + } + + if (ret == -1) { + for (spA8 = g_Dialog.string_index[g_Dialog.u8.active_zoombox]; CMD(spA8)->cmd == g_Dialog.string_cmd[g_Dialog.u8.active_zoombox] && spA8 - g_Dialog.string_index[g_Dialog.u8.active_zoombox] < 8; spA8++) { + sp4C[spA8 - g_Dialog.string_index[g_Dialog.u8.active_zoombox]] = CMD(spA8)->str; + } + + func_80318284(g_Dialog.zoombox[g_Dialog.u8.active_zoombox], spA8 - g_Dialog.string_index[g_Dialog.u8.active_zoombox], sp4C); + g_Dialog.string_index[g_Dialog.u8.active_zoombox] = spA8; + } else { + func_803183A4(g_Dialog.zoombox[g_Dialog.u8.active_zoombox], g_Dialog.output); + g_Dialog.string_index[g_Dialog.u8.active_zoombox]++; + } + + gcdialog_setState(3); + } + break; + } + } + break; + + case 3: + if ((g_Dialog.u8.unk128_31 & 1) && controller_face_buttons[FACE_BUTTON(BUTTON_B)] == 1u) { + gcdialog_setState(6); break; + } + + if (g_Dialog.u8.unk128_31 & 0x80) { + break; + } + + if (NOT((g_Dialog.u8.unk128_31 & 0x80) ? func_8024E5E8(0, 4) : func_8024E5E8(0, 3))) { + break; + } + + gcdialog_setState(6); + break; + + case 4: // Waiting for player to make choice + if (controller_face_buttons[FACE_BUTTON(BUTTON_A)] == 1) { + g_Dialog.u8.unk12C_23 = 1; + } else if (controller_face_buttons[FACE_BUTTON(BUTTON_B)] == 1) { + g_Dialog.u8.unk12C_23 = 0; + } + + if (g_Dialog.u8.unk12C_23 != -1) { + gcdialog_setState(g_Dialog.unk11A[g_Dialog.u8.active_zoombox].unk0_7 ? 8 : 5); + } + break; + + case 7: + case 8: + gcdialog_setState(0); + break; } for(i = 0; i < 2; i++){ - gczoombox_update(D_80382E20.zoombox[i]); + gczoombox_update(g_Dialog.zoombox[i]); } } -#endif //parses text asset into seperate strings void func_80310574(s32 text_id){ @@ -580,12 +624,12 @@ void func_80310574(s32 text_id){ char ch; s32 len; - txt = D_80382E20.dialog_bin_ptr = dialogBin_get(text_id); + txt = g_Dialog.dialog_bin_ptr = dialogBin_get(text_id); for(i = 0; i < 2; i++){ - D_80382E20.string_count[i] = *(txt++); - D_80382E20.string_list[i] = (struct13s *) malloc(D_80382E20.string_count[i]*sizeof(struct13s)); - for(j = 0; j < D_80382E20.string_count[i]; j++){//L803105F0 + g_Dialog.string_count[i] = *(txt++); + g_Dialog.string_list[i] = (struct13s *) malloc(g_Dialog.string_count[i]*sizeof(struct13s)); + for(j = 0; j < g_Dialog.string_count[i]; j++){//L803105F0 ch = *(txt++); if(ch > 0 && ch < 0x20){ _v0 = -ch; @@ -594,10 +638,10 @@ void func_80310574(s32 text_id){ _v0 = (ch >= 0x80)? ch - 0x80 : ch; } - D_80382E20.string_list[i][j].cmd = _v0; + g_Dialog.string_list[i][j].cmd = _v0; len = *(txt); txt++; - D_80382E20.string_list[i][j].str = txt; + g_Dialog.string_list[i][j].str = txt; txt += len; } @@ -620,64 +664,64 @@ void func_803106BC(s32 text_id, s32 arg1, ActorMarker *marker, void(*callback)(A s32 temp_a2; func_80310574(text_id); - D_80382E20.unk12C_29 = 0; - D_80382E20.unk12C_31 = (D_80382E20.unk12C_25 = D_80382E20.unk12C_29); - D_80382E20.unk12C_27 = D_80382E20.unk12C_31; - D_80382E20.unk128_15 = D_80382E20.unk12C_27; + g_Dialog.unk12C_29 = 0; + g_Dialog.unk12C_31 = (g_Dialog.unk12C_25 = g_Dialog.unk12C_29); + g_Dialog.unk12C_27 = g_Dialog.unk12C_31; + g_Dialog.unk128_15 = g_Dialog.unk12C_27; for(j = 0; j < 2; j++){//L80310774 i = 0; - temp_a2 = D_80382E20.string_list[j][0].cmd; - while(D_80382E20.string_list[j][i].cmd < -4 && i < D_80382E20.string_count[j]){ + temp_a2 = g_Dialog.string_list[j][0].cmd; + while(g_Dialog.string_list[j][i].cmd < -4 && i < g_Dialog.string_count[j]){ i++; }; - D_80382E20.string_cmd[j] = temp_a2; + g_Dialog.string_cmd[j] = temp_a2; //L803107C4 - D_80382E20.string[j] = D_80382E20.string_list[j]->str; - D_80382E20.string_index[j] = 0; - D_80382E20.unk124[j] = func_8031068C(j); - D_80382E20.unk11A[j].unk0_5 = 0; - if(D_80382E20.string_list[j][i].cmd >= 0){ - if(!D_80382E20.unk11A[j].unk0_7){ - D_80382E20.zoombox[j] = gczoombox_new(D_80382E20.unk124[j], D_80382E20.string_list[j][i].cmd + 0xC, 0, func_803106A4(j), (void *)func_8030F754); + g_Dialog.string[j] = g_Dialog.string_list[j]->str; + g_Dialog.string_index[j] = 0; + g_Dialog.unk124[j] = func_8031068C(j); + g_Dialog.unk11A[j].unk0_5 = 0; + if(g_Dialog.string_list[j][i].cmd >= 0){ + if(!g_Dialog.unk11A[j].unk0_7){ + g_Dialog.zoombox[j] = gczoombox_new(g_Dialog.unk124[j], g_Dialog.string_list[j][i].cmd + 0xC, 0, func_803106A4(j), (void *)func_8030F754); if( j == 1 ){ func_80347A14(0); } } else{//L80310860 - D_80382E20.unk12C_31++; + g_Dialog.unk12C_31++; } //L80310880 - D_80382E20.unk128_15++; + g_Dialog.unk128_15++; }else{//L80310890 - if(D_80382E20.string_list[j][i].cmd < -2){ - if(D_80382E20.unk11A[j].unk0_7){ - gczoombox_close(D_80382E20.zoombox[j]); - D_80382E20.unk128_15++; + if(g_Dialog.string_list[j][i].cmd < -2){ + if(g_Dialog.unk11A[j].unk0_7){ + gczoombox_close(g_Dialog.zoombox[j]); + g_Dialog.unk128_15++; }else{ - D_80382E20.zoombox[j] = NULL; + g_Dialog.zoombox[j] = NULL; } - D_80382E20.unk11A[j].unk0_7 = 0; + g_Dialog.unk11A[j].unk0_7 = 0; }else{//L803108D8 - if(D_80382E20.unk11A[j].unk0_7){ - D_80382E20.unk128_15++; - D_80382E20.unk12C_31++; + if(g_Dialog.unk11A[j].unk0_7){ + g_Dialog.unk128_15++; + g_Dialog.unk12C_31++; } } }//L80310910 } - D_80382E20.unk130 = text_id; - D_80382E20.unk128_31 = arg1; - if(D_80382E20.string_cmd[0] < 0){ - D_80382E20.active_zoombox = 0; + g_Dialog.unk130 = text_id; + g_Dialog.unk128_31 = arg1; + if(g_Dialog.string_cmd[0] < 0){ + g_Dialog.active_zoombox = 0; }else{//L80310950 - D_80382E20.active_zoombox = 1; + g_Dialog.active_zoombox = 1; }//L8031095C - D_80382E20.unk128_6 = 1; - D_80382E20.unk12C_23 = ((func_802E4A08() || func_803203FC(UNKFLAGS1_1F_IN_CHARACTER_PARADE)) && D_80382E20.unk128_3) ? 1 : -1; - D_80382E20.caller = marker; - D_80382E20.unk13C = callback; - D_80382E20.unk140 = arg4; - D_80382E20.unk144 = (void *)arg5; - D_80382E20.unk138 = (marker != NULL )? ((marker->unk5C)? marker->unk5C : -1) : 0; - gcdialog_setState(((func_802E4A08() || func_803203FC(UNKFLAGS1_1F_IN_CHARACTER_PARADE)) && D_80382E20.unk128_3) ? 6 : 1); + g_Dialog.unk128_6 = 1; + g_Dialog.unk12C_23 = ((func_802E4A08() || func_803203FC(UNKFLAGS1_1F_IN_CHARACTER_PARADE)) && g_Dialog.unk128_3) ? 1 : -1; + g_Dialog.caller = marker; + g_Dialog.unk13C = callback; + g_Dialog.unk140 = arg4; + g_Dialog.unk144 = (void *)arg5; + g_Dialog.unk138 = (marker != NULL )? ((marker->unk5C)? marker->unk5C : -1) : 0; + gcdialog_setState(((func_802E4A08() || func_803203FC(UNKFLAGS1_1F_IN_CHARACTER_PARADE)) && g_Dialog.unk128_3) ? 6 : 1); //L803109EC } @@ -685,8 +729,8 @@ void func_80310A5C(s32 next_state, s32 arg1, s32 arg2, s32 arg3, s32 arg4){ s32 i; f32 tmpf; for(i = 0, tmpf = 0.4f; i< 2; i++){ - if(D_80382E20.zoombox[i]){ - func_803184C8(D_80382E20.zoombox[i], arg2, next_state, arg1, tmpf, arg3, arg4); + if(g_Dialog.zoombox[i]){ + func_803184C8(g_Dialog.zoombox[i], arg2, next_state, arg1, tmpf, arg3, arg4); } } } @@ -702,39 +746,39 @@ void func_80310B1C(s32 text_id, s32 arg1, ActorMarker *marker, void(*callback)(A } void func_80310BB4(s32 next_state, s32 arg1, s32 arg2){ - func_80310A5C(arg1, arg2, next_state, D_80382E20.unk128_31 & 2, D_80382E20.unk128_31 & 0x80); + func_80310A5C(arg1, arg2, next_state, g_Dialog.unk128_31 & 2, g_Dialog.unk128_31 & 0x80); } void func_80310BFC(void){ s32 ch; - if(D_80382E20.unk128_4){ - D_80382E20.unk132++; - ch = D_8036C4D0[D_80382E20.unk132]; - if(D_80382E20.zoombox[0] != NULL){ - D_80382E20.unk124[0] -= ch; - func_80318B7C(D_80382E20.zoombox[0], D_80382E20.unk124[0]); + if(g_Dialog.unk128_4){ + g_Dialog.unk132++; + ch = D_8036C4D0[g_Dialog.unk132]; + if(g_Dialog.zoombox[0] != NULL){ + g_Dialog.unk124[0] -= ch; + func_80318B7C(g_Dialog.zoombox[0], g_Dialog.unk124[0]); }//L80310C60 - if(D_80382E20.zoombox[1] != NULL){ - D_80382E20.unk124[1] += ch; - func_80318B7C(D_80382E20.zoombox[1], D_80382E20.unk124[1]); + if(g_Dialog.zoombox[1] != NULL){ + g_Dialog.unk124[1] += ch; + func_80318B7C(g_Dialog.zoombox[1], g_Dialog.unk124[1]); }//L80310C84 - if(D_80382E20.unk132 == 0xC){ - D_80382E20.unk128_5 = 0; + if(g_Dialog.unk132 == 0xC){ + g_Dialog.unk128_5 = 0; } }else{//L80310CA4 - D_80382E20.unk132--; - ch = D_8036C4D0[D_80382E20.unk132]; - if(D_80382E20.zoombox[0] != NULL){ - D_80382E20.unk124[0] += ch; - func_80318B7C(D_80382E20.zoombox[0], D_80382E20.unk124[0]); + g_Dialog.unk132--; + ch = D_8036C4D0[g_Dialog.unk132]; + if(g_Dialog.zoombox[0] != NULL){ + g_Dialog.unk124[0] += ch; + func_80318B7C(g_Dialog.zoombox[0], g_Dialog.unk124[0]); } - if(D_80382E20.zoombox[1] != NULL){ - D_80382E20.unk124[1] -= ch; - func_80318B7C(D_80382E20.zoombox[1], D_80382E20.unk124[1]); + if(g_Dialog.zoombox[1] != NULL){ + g_Dialog.unk124[1] -= ch; + func_80318B7C(g_Dialog.zoombox[1], g_Dialog.unk124[1]); } - if(D_80382E20.unk132 == 0){ - D_80382E20.unk128_5 = 0; + if(g_Dialog.unk132 == 0){ + g_Dialog.unk128_5 = 0; } } } @@ -742,45 +786,45 @@ void func_80310BFC(void){ void func_80310D2C(void){ struct14s * sp24; - if(D_80382E20.unk128_5) + if(g_Dialog.unk128_5) func_80310BFC(); if(getGameMode() == GAME_MODE_3_NORMAL || func_802E4A08()){ - if(D_80382E20.unk128_5) + if(g_Dialog.unk128_5) return; - if(!func_803114B0() && (s32)(D_80382E20.unk12C_15) > 0){ + if(!func_803114B0() && (s32)(g_Dialog.unk12C_15) > 0){ - sp24 = D_80382E20.unk148 + D_80382E20.unk12C_11; + sp24 = g_Dialog.unk148 + g_Dialog.unk12C_11; func_80310B1C(sp24->unk0,sp24->unk2, sp24->unk10, sp24->unk18, sp24->unk1C, sp24->unk20); - D_80382E20.unk138 = sp24->unk14; + g_Dialog.unk138 = sp24->unk14; func_8025A55C(8000, 300, 2); - if((sp24->unk2 & 0x8) && !((func_802E4A08() || func_803203FC(UNKFLAGS1_1F_IN_CHARACTER_PARADE)) && D_80382E20.unk128_3)){//L80310E6C + if((sp24->unk2 & 0x8) && !((func_802E4A08() || func_803203FC(UNKFLAGS1_1F_IN_CHARACTER_PARADE)) && g_Dialog.unk128_3)){//L80310E6C func_8028F918(0); if( 0.0f == sp24->unk4_x && 0.0f == sp24->unk4_y && 0.0f == sp24->unk4_z ){ - func_8028F918((D_80382E20.string_cmd[1] < 0)? 1 : 3); + func_8028F918((g_Dialog.string_cmd[1] < 0)? 1 : 3); } else{//L80310F00 - func_8028F94C((D_80382E20.string_cmd[1] < 0)? 1 : 3, sp24->unk4); + func_8028F94C((g_Dialog.string_cmd[1] < 0)? 1 : 3, sp24->unk4); } } //L80310F28 - D_80382E20.unk12C_11++; - if(!((s32) D_80382E20.unk12C_11 < 4)){ - D_80382E20.unk12C_11 = D_80382E20.unk12C_11 - 4; + g_Dialog.unk12C_11++; + if(!((s32) g_Dialog.unk12C_11 < 4)){ + g_Dialog.unk12C_11 = g_Dialog.unk12C_11 - 4; } - D_80382E20.unk12C_15--; + g_Dialog.unk12C_15--; }else{//L80310F88 gcdialog_update(); }//L80310F98 - if( ( D_80382E20.state != 0 && D_80382E20.state != 5 && D_80382E20.state != 7) - || ((!D_80382E20.state && (D_80382E20.unk11A[0].unk0_7 || D_80382E20.unk11A[1].unk0_7))) - || D_80382E20.unk12C_15 + if( ( g_Dialog.state != 0 && g_Dialog.state != 5 && g_Dialog.state != 7) + || ((!g_Dialog.state && (g_Dialog.unk11A[0].unk0_7 || g_Dialog.unk11A[1].unk0_7))) + || g_Dialog.unk12C_15 ){ //L80310FF0 if(func_802FADD4(0)){ @@ -838,11 +882,11 @@ int func_80311174(s32 text_id, s32 arg1, f32 *pos, ActorMarker *marker, void(*ca if(!func_803114B0()){ func_80310B1C(text_id, arg1, marker, (void *)callback, (void *)arg5, arg6); if(arg1 & 8){ - if(!(func_802E4A08() || func_803203FC(UNKFLAGS1_1F_IN_CHARACTER_PARADE)) || !D_80382E20.unk128_3){//L80311214 + if(!(func_802E4A08() || func_803203FC(UNKFLAGS1_1F_IN_CHARACTER_PARADE)) || !g_Dialog.unk128_3){//L80311214 if(pos != NULL){ - func_8028F94C(((D_80382E20.string_cmd[1] < 0)? 1 : 3), pos); + func_8028F94C(((g_Dialog.string_cmd[1] < 0)? 1 : 3), pos); }else{//L8031126C - func_8028F918(((D_80382E20.string_cmd[1] < 0)? 1 : 3)); + func_8028F918(((g_Dialog.string_cmd[1] < 0)? 1 : 3)); } } }//L8031128C @@ -850,40 +894,40 @@ int func_80311174(s32 text_id, s32 arg1, f32 *pos, ActorMarker *marker, void(*ca return 1; }else{//L803112A0 if(arg1 & 0x20){ - if(!(D_80382E20.unk128_31 & 0x80)){ + if(!(g_Dialog.unk128_31 & 0x80)){ func_803114D0(); } else{ - D_80382E20.unk12C_15 = 0; - D_80382E20.unk12C_11 = 0; + g_Dialog.unk12C_15 = 0; + g_Dialog.unk12C_11 = 0; } }//L803112E8 if(arg1 & 0x04 || arg1 & 0x20){ //L80311300 - temp_v1 = D_80382E20.unk12C_11 + D_80382E20.unk12C_15; + temp_v1 = g_Dialog.unk12C_11 + g_Dialog.unk12C_15; temp_v1 = (temp_v1 < 4)?temp_v1 : temp_v1 - 4; //L80311328 - D_80382E20.unk148[temp_v1].unk0 = text_id; - D_80382E20.unk148[temp_v1].unk2 = arg1; + g_Dialog.unk148[temp_v1].unk0 = text_id; + g_Dialog.unk148[temp_v1].unk2 = arg1; if(pos){ - D_80382E20.unk148[temp_v1].unk4[0] = pos[0]; - D_80382E20.unk148[temp_v1].unk4[1] = pos[1]; - D_80382E20.unk148[temp_v1].unk4[2] = pos[2]; + g_Dialog.unk148[temp_v1].unk4[0] = pos[0]; + g_Dialog.unk148[temp_v1].unk4[1] = pos[1]; + g_Dialog.unk148[temp_v1].unk4[2] = pos[2]; } else{ - D_80382E20.unk148[temp_v1].unk4[2] = 0.0f; - D_80382E20.unk148[temp_v1].unk4[1] = 0.0f; - D_80382E20.unk148[temp_v1].unk4[0] = 0.0f; + g_Dialog.unk148[temp_v1].unk4[2] = 0.0f; + g_Dialog.unk148[temp_v1].unk4[1] = 0.0f; + g_Dialog.unk148[temp_v1].unk4[0] = 0.0f; } - D_80382E20.unk148[temp_v1].unk10 = marker; - D_80382E20.unk148[temp_v1].unk14 = (marker != NULL )? ((marker->unk5C)? marker->unk5C : -1) : 0; - D_80382E20.unk148[temp_v1].unk18 = (void *)callback; - D_80382E20.unk148[temp_v1].unk1C = (void *)arg5; - D_80382E20.unk148[temp_v1].unk20 = arg6; - D_80382E20.unk12C_15++; + g_Dialog.unk148[temp_v1].unk10 = marker; + g_Dialog.unk148[temp_v1].unk14 = (marker != NULL )? ((marker->unk5C)? marker->unk5C : -1) : 0; + g_Dialog.unk148[temp_v1].unk18 = (void *)callback; + g_Dialog.unk148[temp_v1].unk1C = (void *)arg5; + g_Dialog.unk148[temp_v1].unk20 = arg6; + g_Dialog.unk12C_15++; if(arg1 & 0x08){ - if(!( func_802E4A08() || func_803203FC(0x1f, &D_80382E20)) || !D_80382E20.unk128_3){//L8031141C + if(!( func_802E4A08() || func_803203FC(0x1f, &g_Dialog)) || !g_Dialog.unk128_3){//L8031141C if(!func_8028EC04()){ if(pos != NULL){ func_8028F94C(2, pos); @@ -908,11 +952,11 @@ bool func_80311480(s32 text_id, s32 arg1, f32 *pos, ActorMarker *marker, void(*c } int func_803114B0(void){ - return (D_80382E20.unk130 + 1) != 0; + return (g_Dialog.unk130 + 1) != 0; } int func_803114C4(void){ - return D_80382E20.unk130; + return g_Dialog.unk130; } void func_803114D0(void){ @@ -921,21 +965,21 @@ void func_803114D0(void){ if(func_803114B0()){ gcdialog_setState(6); }else{ - if(D_80382E20.state != 6){ - D_80382E20.unk12C_25 = 0; + if(g_Dialog.state != 6){ + g_Dialog.unk12C_25 = 0; for(i = 0; i< 2; i++){ - D_80382E20.unk11A[i].unk0_7 = 0; - if(D_80382E20.zoombox[i]){ - D_80382E20.unk12C_25 += (u8)func_803188B4(D_80382E20.zoombox[i]); + g_Dialog.unk11A[i].unk0_7 = 0; + if(g_Dialog.zoombox[i]){ + g_Dialog.unk12C_25 += (u8)func_803188B4(g_Dialog.zoombox[i]); } } - if(D_80382E20.unk12C_25 != 0){ - D_80382E20.state = 6; + if(g_Dialog.unk12C_25 != 0){ + g_Dialog.state = 6; } } }//L80311594 - D_80382E20.unk12C_15 = 0; - D_80382E20.unk12C_11 = 0; + g_Dialog.unk12C_15 = 0; + g_Dialog.unk12C_11 = 0; } @@ -950,17 +994,17 @@ int func_803115C4(s32 next_state){ void func_80311604(void){ if(func_803114B0()){ - D_80382E20.unk128_5 = 1; - D_80382E20.unk128_4 = 0; - D_80382E20.unk132++; + g_Dialog.unk128_5 = 1; + g_Dialog.unk128_4 = 0; + g_Dialog.unk132++; } } void func_80311650(void){ if(func_803114B0()){ - D_80382E20.unk128_5 = 1; - D_80382E20.unk128_4 = 1; - D_80382E20.unk132--; + g_Dialog.unk128_5 = 1; + g_Dialog.unk128_4 = 1; + g_Dialog.unk132--; } } @@ -968,16 +1012,16 @@ void gcdialog_defrag(void){ s32 i; for(i = 0; i< 2; i++){ - func_80318C0C(D_80382E20.zoombox[i]); - if(D_80382E20.string_list[i]){ - D_80382E20.string_list[i] = (struct13s *)defrag(D_80382E20.string_list[i]); + func_80318C0C(g_Dialog.zoombox[i]); + if(g_Dialog.string_list[i]){ + g_Dialog.string_list[i] = (struct13s *)defrag(g_Dialog.string_list[i]); } - if(D_80382E20.zoombox[i] != NULL){ - D_80382E20.zoombox[i] = (gczoombox_t *)defrag(D_80382E20.zoombox[i]); + if(g_Dialog.zoombox[i] != NULL){ + g_Dialog.zoombox[i] = (gczoombox_t *)defrag(g_Dialog.zoombox[i]); } } } void func_80311714(int next_state){ - D_80382E20.unk128_3 = next_state; + g_Dialog.unk128_3 = next_state; }