From 24d5f9cfaff220d9d1b292e386a18f883474b1e3 Mon Sep 17 00:00:00 2001 From: gamemasterplc Date: Fri, 22 Dec 2023 14:18:26 -0600 Subject: [PATCH 1/4] Do initial cleanup of window code --- config/GMPE01_00/symbols.txt | 12 +- include/game/window.h | 136 +++--- src/game/window.c | 923 ++++++++++++++++++----------------- 3 files changed, 535 insertions(+), 536 deletions(-) diff --git a/config/GMPE01_00/symbols.txt b/config/GMPE01_00/symbols.txt index 8162dbd0..338fb54d 100644 --- a/config/GMPE01_00/symbols.txt +++ b/config/GMPE01_00/symbols.txt @@ -6187,13 +6187,13 @@ winTabSize = .sbss:0x801D3DC9; // type:object size:0x1 scope:local data:byte mesWInsert = .sbss:0x801D3DCA; // type:object size:0x8 scope:local winMaxHeight = .sbss:0x801D3DD2; // type:object size:0x2 scope:local data:2byte winMaxWidth = .sbss:0x801D3DD4; // type:object size:0x2 scope:local data:2byte -messDataNo = .sbss:0x801D3DD8; // type:object size:0x4 data:4byte +messDataNo = .sbss:0x801D3DD8; // type:object size:0x4 scope:local data:4byte messDataPtr = .sbss:0x801D3DDC; // type:object size:0x4 data:4byte -winProc = .sbss:0x801D3DE0; // type:object size:0x4 data:4byte -cardAnimB = .sbss:0x801D3DE4; // type:object size:0x4 data:4byte -cardAnimA = .sbss:0x801D3DE8; // type:object size:0x4 data:4byte -cursorAnim = .sbss:0x801D3DEC; // type:object size:0x4 data:4byte -iconAnim = .sbss:0x801D3DF0; // type:object size:0x8 data:4byte +winProc = .sbss:0x801D3DE0; // type:object size:0x4 scope:local data:4byte +cardAnimB = .sbss:0x801D3DE4; // type:object size:0x4 scope:local data:4byte +cardAnimA = .sbss:0x801D3DE8; // type:object size:0x4 scope:local data:4byte +cursorAnim = .sbss:0x801D3DEC; // type:object size:0x4 scope:local data:4byte +iconAnim = .sbss:0x801D3DF0; // type:object size:0x4 scope:local data:4byte UnMountCnt = .sbss:0x801D3DF8; // type:object size:0x1 data:byte cardWork = .sbss:0x801D3DFC; // type:object size:0x4 scope:local data:4byte arqIdx = .sbss:0x801D3E00; // type:object size:0x2 scope:local data:2byte diff --git a/include/game/window.h b/include/game/window.h index 3c1988af..d4009df6 100644 --- a/include/game/window.h +++ b/include/game/window.h @@ -2,87 +2,77 @@ #define _GAME_WINDOW_H #include "game/sprite.h" +#include "dolphin.h" + typedef struct { - /* 0x00 */ u8 unk00; - /* 0x01 */ u8 unk01; - /* 0x02 */ s16 unk02; - /* 0x04 */ s16 unk04; - /* 0x06 */ s16 unk06; -} UnknownWindowStruct1; // Size 8 + /* 0x00 */ u8 color; + /* 0x01 */ u8 fade; + /* 0x02 */ s16 x; + /* 0x04 */ s16 y; + /* 0x06 */ s16 character; +} WinChar; // Size 8 typedef struct { - /* 0x00 */ u8 unk00; - /* 0x01 */ char unk01[1]; - /* 0x02 */ s16 unk02; - /* 0x04 */ s16 unk04; -} UnknownWindowStruct2; // Size 6 + /* 0x00 */ u8 stat; + /* 0x02 */ s16 x; + /* 0x04 */ s16 y; +} WinChoice; // Size 6 typedef struct { - /* 0x000 */ u8 unk00; - /* 0x001 */ u8 unk01; - /* 0x002 */ u8 unk02; - /* 0x003 */ u8 unk03; - /* 0x004 */ s16 unk04; - /* 0x006 */ s16 unk06[30]; - /* 0x042 */ s16 unk42; - /* 0x044 */ s16 unk44; - /* 0x046 */ s16 unk46; - /* 0x048 */ s16 unk48; - /* 0x04A */ char unk4A[2]; - /* 0x04C */ u32 unk4C; - /* 0x050 */ AnimData* unk50; - /* 0x054 */ s16 unk54; - /* 0x056 */ s16 unk56; - /* 0x058 */ s16 unk58; - /* 0x05A */ s16 unk5A; - /* 0x05C */ s16 unk5C; - /* 0x05E */ s16 unk5E; - /* 0x060 */ s16 unk60; - /* 0x062 */ s16 unk62; - /* 0x064 */ s16 unk64; - /* 0x066 */ s16 unk66; - /* 0x068 */ s16 unk68; - /* 0x06A */ s16 unk6A; - /* 0x06C */ f32 unk6C; - /* 0x070 */ f32 unk70; - /* 0x074 */ f32 unk74; - /* 0x078 */ f32 unk78; - /* 0x07C */ f32 unk7C; - /* 0x080 */ s16 unk80; - /* 0x082 */ s16 unk82; - /* 0x084 */ UnknownWindowStruct1* unk84; - /* 0x088 */ s16 unk88; - /* 0x08A */ char unk8A[2]; + /* 0x000 */ u8 stat; + /* 0x001 */ u8 active_pad; + /* 0x002 */ u8 player_disable; + /* 0x003 */ u8 color_key; + /* 0x004 */ s16 group; + /* 0x006 */ s16 sprite_id[30]; + /* 0x042 */ s16 speed; + /* 0x044 */ s16 mess_time; + /* 0x046 */ s16 advance_sprite; + /* 0x048 */ s16 prio; + /* 0x04C */ u32 attr; + /* 0x050 */ AnimData *frame; + /* 0x054 */ s16 mess_rect_x; + /* 0x056 */ s16 mess_rect_w; + /* 0x058 */ s16 mess_rect_y; + /* 0x05A */ s16 mess_rect_h; + /* 0x05C */ s16 mess_x; + /* 0x05E */ s16 mess_y; + /* 0x060 */ s16 mess_color; + /* 0x062 */ s16 mess_shadow_color; + /* 0x064 */ s16 spacing_x; + /* 0x066 */ s16 spacing_y; + /* 0x068 */ s16 w; + /* 0x06A */ s16 h; + /* 0x06C */ f32 pos_x; + /* 0x070 */ f32 pos_y; + /* 0x074 */ f32 scale_x; + /* 0x078 */ f32 scale_y; + /* 0x07C */ f32 rot; + /* 0x080 */ s16 num_chars; + /* 0x082 */ s16 max_chars; + /* 0x084 */ WinChar *char_data; + /* 0x088 */ s16 mess_stackptr; /* 0x08C */ s32 unk8C; - /* 0x090 */ u8* unk90; - /* 0x094 */ u8* unk94[1]; // unknown size - /* 0x098 */ char unk98[0x1C]; - /* 0x0B4 */ void* unkB4[8]; - /* 0x0D4 */ s16 unkD4; - /* 0x0D6 */ s16 unkD6; - /* 0x0D8 */ s16 unkD8; - /* 0x0DA */ u8 unkDA[16]; - /* 0x0EA */ UnknownWindowStruct2 unkEA[16]; - /* 0x14A */ s16 unk14A; - /* 0x14C */ s16 unk14C; - /* 0x14E */ s16 unk14E; - /* 0x150 */ s16 unk150; - /* 0x152 */ s16 unk152; - /* 0x154 */ s16 unk154; - /* 0x156 */ s16 unk156; - /* 0x158 */ s16 unk158; - /* 0x15A */ char unk15A[6]; - /* 0x160 */ u8 unk160[10][3]; - /* 0x17E */ char unk17E[2]; + /* 0x090 */ u8 *mess; + /* 0x094 */ u8 *mess_stack[8]; + /* 0x0B4 */ u8 *insert_mess[8]; + /* 0x0D4 */ s16 num_choices; + /* 0x0D6 */ s16 choice; + /* 0x0D8 */ s16 cursor_sprite; + /* 0x0DA */ u8 choice_disable[16]; + /* 0x0EA */ WinChoice choice_data[16]; + /* 0x14A */ s16 scissor_x; + /* 0x14C */ s16 scissor_y; + /* 0x14E */ s16 scissor_w; + /* 0x150 */ s16 scissor_h; + /* 0x152 */ s16 char_w; + /* 0x154 */ s16 push_key; + /* 0x156 */ s16 key_down; + /* 0x158 */ s16 key_auto; + /* 0x160 */ u8 ATTRIBUTE_ALIGN(32) mess_pal[10][3]; } SomeWindowStruct; // Size 0x180 -typedef struct { - /* 0x00 */ u8 r; - /* 0x01 */ u8 g; - /* 0x02 */ u8 b; -} ColorRGB; // Size 3 - void HuWindowInit(void); void HuWinInit(s32 arg0); s16 HuWinCreate(f32 x, f32 y, s16 w, s16 h, s16 frame); @@ -105,7 +95,7 @@ u8 HuWinStatGet(s16 arg0); void HuWinMesColSet(s16 arg0, u8 arg1); void HuWinMesPalSet(s16 arg0, u8 arg1, u8 arg2, u8 arg3, u8 arg4); void HuWinBGTPLvlSet(s16 arg0, f32 arg1); -void HuWinBGColSet(s16 arg0, ColorRGB* arg1); +void HuWinBGColSet(s16 arg0, GXColor *arg1); void HuWinMesSpeedSet(s16 arg0, s16 arg1); void HuWinMesRead(s32 arg0); void HuWinMesSet(s16 arg0, u32 arg1); diff --git a/src/game/window.c b/src/game/window.c index 86f51aeb..c5e6335a 100644 --- a/src/game/window.c +++ b/src/game/window.c @@ -1,27 +1,31 @@ #include "common.h" + #include "game/window.h" +#include "game/sprite.h" +#include "game/data.h" +#include "game/dvd.h" #include "game/memory.h" #include "game/process.h" +#include "math.h" #include "stdarg.h" #include "string.h" #define M_PI 3.141592653589793 typedef struct { - /* 0x00 */ AnimData** unk00; - /* 0x04 */ s16 unk04; - /* 0x06 */ s16 unk06; - /* 0x08 */ s16 unk08; - /* 0x0A */ s16 unk0A; - /* 0x0C */ s16 unk0C; -} SomeFontTblStruct; // Size 0x10 + /* 0x00 */ AnimData **anim; + /* 0x04 */ s16 bank; + /* 0x06 */ s16 w; + /* 0x08 */ s16 h; + /* 0x0A */ s16 center_x; + /* 0x0C */ s16 center_y; +} spcFontTblData; typedef struct { - /* 0x00 */ s16 unk00; - /* 0x02 */ char unk02[2]; - /* 0x04 */ s32 unk04[4]; -} SomeKeyBufStruct; // Size 0x14 + /* 0x00 */ s16 time; + /* 0x04 */ u32 player[4]; +} keyBufData; // Size 0x14 static void MesDispFunc(SpriteData*); static u8 winBGMake(AnimData*, AnimData*); @@ -42,10 +46,8 @@ s32 HuAudFXPlay(s32); void HuAR_ARAMtoMRAM(void*); void HuDataDirClose(s32); void* HuDataReadNum(s32, s32); -f64 cos(f64); -f64 sin(f64); + void mtxTransCat(Mtx, f32, f32, f32); -void* HuDvdDataRead(char*); void* MessData_MesPtrGet(void*, u32); extern u16 HuPadBtn[4]; @@ -53,30 +55,30 @@ extern u8 HuPadDStkRep[4]; SomeWindowStruct ATTRIBUTE_ALIGN(32) winData[32]; u32 winKey[4]; -SomeKeyBufStruct winComKeyBuf[256]; +keyBufData winComKeyBuf[256]; -AnimData* iconAnim; -AnimData* cursorAnim; -AnimData* cardAnimA; -AnimData* cardAnimB; -Process* winProc; +static AnimData *iconAnim; +static AnimData *cursorAnim; +static AnimData *cardAnimA; +static AnimData *cardAnimB; +static Process *winProc; void* messDataPtr; -s32 messDataNo; +static s32 messDataNo; static s16 winMaxWidth; static s16 winMaxHeight; static u8 mesWInsert[8]; static u8 winTabSize; static u8 winInsertF; -static void* winAMemP; -static u8* fontWidthP; +static void *winAMemP; +static u8 *fontWidthP; static s32 cancelCRF; static s16 mesCharCnt; static s16 comKeyIdxNow; static s16 comKeyIdx; static u8 LanguageNo; -AnimData* fontAnim; +AnimData *fontAnim; -static SomeFontTblStruct spcFontTbl[] = { +static spcFontTblData spcFontTbl[] = { { &iconAnim, 0, 20, 24, 10, 12 }, { &iconAnim, 1, 20, 24, 10, 12 }, { &iconAnim, 2, 20, 24, 10, 12 }, @@ -101,6 +103,7 @@ static SomeFontTblStruct spcFontTbl[] = { { &cardAnimA, 0, 32, 32, 16, 16 }, { &cardAnimB, 0, 32, 32, 16, 16 } }; + u8 charWETbl[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -122,6 +125,7 @@ u8 charWETbl[] = { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20 }; + u8 charWJTbl[] = { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 20, 20, 20, @@ -144,7 +148,8 @@ u8 charWJTbl[] = { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20 }; -static u8 ATTRIBUTE_ALIGN(32) charColPal[] = { + +static u8 ATTRIBUTE_ALIGN(32) charColPal[2*3*10] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, @@ -166,18 +171,21 @@ static u8 ATTRIBUTE_ALIGN(32) charColPal[] = { 0x60, 0x60, 0x60, 0x90, 0x90, 0x90 }; + static s32 frameFileTbl[] = { - 0x00860006, - 0x00860007, - 0x00860008, - 0x00860006 + MAKE_DATA_NUM(DATADIR_WIN, 6), + MAKE_DATA_NUM(DATADIR_WIN, 7), + MAKE_DATA_NUM(DATADIR_WIN, 8), + MAKE_DATA_NUM(DATADIR_WIN, 6) }; + static char* mesDataTbl[] = { "mess/mini.dat", "mess/board.dat", "mess/mini_e.dat", "mess/board_e.dat" }; + static s32 winVoiceTbl[] = { 0x37, 0x36, 0x38, 0x44, 0x43, 0x45, 0x41, 0x40, @@ -190,11 +198,11 @@ static s32 winVoiceTbl[] = { s16 winPrio = 1000; void HuWindowInit(void) { - s16 var_r31; + s16 i; - winAMemP = HuAR_DVDtoARAM(0x860000); - for (var_r31 = 0; var_r31 < 32; var_r31++) { - winData[var_r31].unk04 = -1; + winAMemP = HuAR_DVDtoARAM(MAKE_DIR_NUM(DATADIR_WIN)); + for (i = 0; i < 32; i++) { + winData[i].group = -1; } winProc = 0; winPrio = 1000; @@ -215,37 +223,37 @@ void HuWinInit(s32 arg0) { fontWidthP = (LanguageNo == 0) ? charWJTbl : charWETbl; HuWinMesRead(arg0); for (var_r30 = 0; var_r30 < 32; var_r30++) { - winData[var_r30].unk04 = -1; + winData[var_r30].group = -1; } - if (fontAnim == 0) { + if (!fontAnim) { if (LanguageNo == 0) { - var_r31 = HuDataReadNum(0x860000, 0x10000000); + var_r31 = HuDataReadNum(MAKE_DATA_NUM(DATADIR_WIN, 0), MEMORY_DEFAULT_NUM); } else { - var_r31 = HuDataReadNum(0x860001, 0x10000000); + var_r31 = HuDataReadNum(MAKE_DATA_NUM(DATADIR_WIN, 1), MEMORY_DEFAULT_NUM); } fontAnim = HuSprAnimRead(var_r31); } - if (iconAnim == 0) { - var_r31 = HuDataReadNum(0x860003, 0x10000000); + if (!iconAnim) { + var_r31 = HuDataReadNum(MAKE_DATA_NUM(DATADIR_WIN, 3), MEMORY_DEFAULT_NUM); iconAnim = HuSprAnimRead(var_r31); HuSprAnimLock(iconAnim); } - if (cursorAnim == 0) { - var_r31 = HuDataReadNum(0x860002, 0x10000000); + if (!cursorAnim) { + var_r31 = HuDataReadNum(MAKE_DATA_NUM(DATADIR_WIN, 2), MEMORY_DEFAULT_NUM); cursorAnim = HuSprAnimRead(var_r31); HuSprAnimLock(cursorAnim); } - if (cardAnimA == 0) { - var_r31 = HuDataReadNum(0x860004, 0x10000000); + if (!cardAnimA) { + var_r31 = HuDataReadNum(MAKE_DATA_NUM(DATADIR_WIN, 4), MEMORY_DEFAULT_NUM); cardAnimA = HuSprAnimRead(var_r31); HuSprAnimLock(cardAnimA); } - if (cardAnimB == 0) { - var_r31 = HuDataReadNum(0x860005, 0x10000000); + if (!cardAnimB) { + var_r31 = HuDataReadNum(MAKE_DATA_NUM(DATADIR_WIN, 5), MEMORY_DEFAULT_NUM); cardAnimB = HuSprAnimRead(var_r31); HuSprAnimLock(cardAnimB); } - HuDataDirClose(0x860000); + HuDataDirClose(MAKE_DIR_NUM(DATADIR_WIN)); HuWinComKeyReset(); winPrio = 1000; } @@ -262,7 +270,7 @@ s16 HuWinCreate(f32 x, f32 y, s16 w, s16 h, s16 frame) { void* temp_r21; for (var_r29 = 0; var_r29 < 32; var_r29++) { - if (winData[var_r29].unk04 == -1) { + if (winData[var_r29].group == -1) { break; } } @@ -270,86 +278,86 @@ s16 HuWinCreate(f32 x, f32 y, s16 w, s16 h, s16 frame) { return -1; } temp_r31 = &winData[var_r29]; - temp_r31->unk04 = temp_r3 = HuSprGrpCreate(0x1E); + temp_r31->group = temp_r3 = HuSprGrpCreate(0x1E); if (frame < 0 || frame >= 4) { frame = 0; } w = (w + 0xF) & 0xFFF0; h = (h + 0xF) & 0xFFF0; if (x == -10000.0f) { - temp_r31->unk6C = (576.0f - w) / 2; + temp_r31->pos_x = (576.0f - w) / 2; } else { - temp_r31->unk6C = x; + temp_r31->pos_x = x; } if (y == -10000.0f) { - temp_r31->unk70 = (480.0f - h) / 2; + temp_r31->pos_y = (480.0f - h) / 2; } else { - temp_r31->unk70 = y; + temp_r31->pos_y = y; } HuSprGrpCenterSet(temp_r3, w / 2, h / 2); - HuSprGrpPosSet(temp_r3, temp_r31->unk6C, temp_r31->unk70); - temp_r21 = HuAR_ARAMtoMRAMFileRead(frameFileTbl[frame], 0x10000000, 2); - temp_r31->unk50 = HuSprAnimRead(temp_r21); - temp_r3_2 = temp_r31->unk06[0] = HuSprCreate(temp_r31->unk50, winPrio, 0); + HuSprGrpPosSet(temp_r3, temp_r31->pos_x, temp_r31->pos_y); + temp_r21 = HuAR_ARAMtoMRAMFileRead(frameFileTbl[frame], MEMORY_DEFAULT_NUM, 2); + temp_r31->frame = HuSprAnimRead(temp_r21); + temp_r3_2 = temp_r31->sprite_id[0] = HuSprCreate(temp_r31->frame, winPrio, 0); HuSprGrpMemberSet(temp_r3, 0, temp_r3_2); HuSprTPLvlSet(temp_r3, 0, 0.9f); temp_r3_3 = HuSprAnimMake(w / 16, h / 16, 6); HuSprBGSet(temp_r3, 0, temp_r3_3, 0); - temp_r31->unk03 = winBGMake(temp_r3_3, temp_r31->unk50); - temp_r3_2 = temp_r31->unk06[1] = HuSprFuncCreate(MesDispFunc, winPrio); + temp_r31->color_key = winBGMake(temp_r3_3, temp_r31->frame); + temp_r3_2 = temp_r31->sprite_id[1] = HuSprFuncCreate(MesDispFunc, winPrio); temp_r22 = &HuSprData[temp_r3_2]; temp_r22->work[0] = var_r29; HuSprGrpMemberSet(temp_r3, 1, temp_r3_2); - temp_r31->unk80 = 0; - temp_r31->unk82 = (w / 8) * (h / 24) * 4; - temp_r31->unk84 = HuMemDirectMalloc(HEAP_SYSTEM, temp_r31->unk82 * sizeof(UnknownWindowStruct1)); - temp_r31->unk4C = 0; - temp_r31->unk00 = 0; + temp_r31->num_chars = 0; + temp_r31->max_chars = (w / 8) * (h / 24) * 4; + temp_r31->char_data = HuMemDirectMalloc(HEAP_SYSTEM, temp_r31->max_chars * sizeof(WinChar)); + temp_r31->attr = 0; + temp_r31->stat = 0; temp_r31->unk8C = 0; - temp_r31->unk44 = 0; - temp_r31->unk5C = temp_r31->unk5E = 0; - temp_r31->unk54 = 8; - temp_r31->unk58 = 8; - temp_r31->unk56 = w - 8; - temp_r31->unk5A = h - 8; - temp_r31->unk42 = 1; - temp_r31->unk60 = 7; - temp_r31->unk62 = 0; - temp_r31->unk01 = 0xF; - temp_r31->unk02 = 0; - temp_r31->unk88 = 0; - temp_r31->unk90 = 0; - temp_r31->unkD4 = 0; - temp_r31->unk48 = winPrio; - temp_r31->unk64 = 1; - temp_r31->unk66 = 2; - temp_r31->unk68 = w; - temp_r31->unk6A = h; - temp_r31->unk14A = temp_r31->unk14C = 0; - temp_r31->unk14E = 0x280; - temp_r31->unk150 = 0x1E0; - temp_r31->unk152 = 0x18; - temp_r31->unk154 = 0x300; - temp_r31->unk158 = 0; + temp_r31->mess_time = 0; + temp_r31->mess_x = temp_r31->mess_y = 0; + temp_r31->mess_rect_x = 8; + temp_r31->mess_rect_y = 8; + temp_r31->mess_rect_w = w - 8; + temp_r31->mess_rect_h = h - 8; + temp_r31->speed = 1; + temp_r31->mess_color = 7; + temp_r31->mess_shadow_color = 0; + temp_r31->active_pad = 0xF; + temp_r31->player_disable = 0; + temp_r31->mess_stackptr = 0; + temp_r31->mess = 0; + temp_r31->num_choices = 0; + temp_r31->prio = winPrio; + temp_r31->spacing_x = 1; + temp_r31->spacing_y = 2; + temp_r31->w = w; + temp_r31->h = h; + temp_r31->scissor_x = temp_r31->scissor_y = 0; + temp_r31->scissor_w = 0x280; + temp_r31->scissor_h = 0x1E0; + temp_r31->char_w = 0x18; + temp_r31->push_key = 0x300; + temp_r31->key_auto = 0; if (frame == 0 || frame == 2) { - memcpy(&temp_r31->unk160, charColPal + 30, 30); + memcpy(&temp_r31->mess_pal, &charColPal[30], 30); } else { - memcpy(&temp_r31->unk160, charColPal, 30); - temp_r31->unk62 = 9; + memcpy(&temp_r31->mess_pal, charColPal, 30); + temp_r31->mess_shadow_color = 9; } for (var_r30 = 0; var_r30 < 8; var_r30++) { - temp_r31->unkB4[var_r30] = 0; + temp_r31->insert_mess[var_r30] = 0; } for (var_r30 = 2; var_r30 < 30; var_r30++) { - temp_r31->unk06[var_r30] = -1; + temp_r31->sprite_id[var_r30] = -1; } winPrio -= 3; if (winPrio < 500) { winPrio = 1000; } for (var_r30 = 0; var_r30 < 16; var_r30++) { - temp_r31->unkDA[var_r30] = 0; - temp_r31->unkEA[var_r30].unk00 = 0; + temp_r31->choice_disable[var_r30] = 0; + temp_r31->choice_data[var_r30].stat = 0; } return var_r29; } @@ -358,15 +366,15 @@ void HuWinKill(s16 arg0) { SomeWindowStruct* temp_r31 = &winData[arg0]; s16 var_r30; - if (temp_r31->unk04 != -1) { - HuMemDirectFree(temp_r31->unk84); + if (temp_r31->group != -1) { + HuMemDirectFree(temp_r31->char_data); for (var_r30 = 2; var_r30 < 30; var_r30++) { - if (temp_r31->unk06[var_r30] != -1) { - HuSprGrpMemberKill(temp_r31->unk04, var_r30); + if (temp_r31->sprite_id[var_r30] != -1) { + HuSprGrpMemberKill(temp_r31->group, var_r30); } } - HuSprGrpKill(temp_r31->unk04); - temp_r31->unk04 = -1; + HuSprGrpKill(temp_r31->group); + temp_r31->group = -1; } } @@ -374,7 +382,7 @@ void HuWinAllKill(void) { s16 var_r30; for (var_r30 = 0; var_r30 < 32; var_r30++) { - if (winData[var_r30].unk04 != -1) { + if (winData[var_r30].group != -1) { HuWinKill(var_r30); } } @@ -427,8 +435,8 @@ static void MesDispFunc(SpriteData* arg0) { Mtx sp50; Mtx44 sp10; - if (temp_r31->unk80 != 0) { - spC = &HuSprGrpData[temp_r31->unk04]; + if (temp_r31->num_chars != 0) { + spC = &HuSprGrpData[temp_r31->group]; GXInvalidateTexAll(); C_MTXOrtho(sp10, 0.0f, 480.0f, 0.0f, 576.0f, 0.0f, 10.0f); GXSetProjection(sp10, GX_ORTHOGRAPHIC); @@ -460,37 +468,37 @@ static void MesDispFunc(SpriteData* arg0) { GXLoadPosMtxImm(sp50, 0); GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); HuSprTexLoad(fontAnim, 0, 0, GX_CLAMP, GX_CLAMP, GX_LINEAR); - GXBegin(GX_QUADS, GX_VTXFMT0, temp_r31->unk80 * 4); + GXBegin(GX_QUADS, GX_VTXFMT0, temp_r31->num_chars * 4); var_f23 = (LanguageNo == 0) ? 0.05882353f : 0.07692308f; - for (var_r29 = 0; var_r29 < temp_r31->unk80; var_r29++) { - temp_f27 = fontWidthP[temp_r31->unk84[var_r29].unk06 + 0x30]; - temp_f29 = 0.0625f * (temp_r31->unk84[var_r29].unk06 % 16); - temp_f28 = var_f23 * (temp_r31->unk84[var_r29].unk06 / 16); + for (var_r29 = 0; var_r29 < temp_r31->num_chars; var_r29++) { + temp_f27 = fontWidthP[temp_r31->char_data[var_r29].character + 0x30]; + temp_f29 = 0.0625f * (temp_r31->char_data[var_r29].character % 16); + temp_f28 = var_f23 * (temp_r31->char_data[var_r29].character / 16); temp_f26 = temp_f29 + (temp_f27 / 320.0); temp_f25 = temp_f28 + var_f23; - temp_f31 = temp_r31->unk84[var_r29].unk02; - temp_f30 = temp_r31->unk84[var_r29].unk04; - temp_r28 = temp_r31->unk84[var_r29].unk00; - if (temp_r31->unk42 != 0) { - temp_r27 = temp_r31->unk84[var_r29].unk01 * 8; + temp_f31 = temp_r31->char_data[var_r29].x; + temp_f30 = temp_r31->char_data[var_r29].y; + temp_r28 = temp_r31->char_data[var_r29].color; + if (temp_r31->speed != 0) { + temp_r27 = temp_r31->char_data[var_r29].fade * 8; } else { temp_r27 = 0xFF; } temp_r27 = 0xFF; - if (temp_r31->unk84[var_r29].unk01 < 0x1F) { - temp_r31->unk84[var_r29].unk01++; + if (temp_r31->char_data[var_r29].fade < 0x1F) { + temp_r31->char_data[var_r29].fade++; } GXPosition3f32(temp_f31 + 1.0f, temp_f30, 0.0f); - GXColor4u8(temp_r31->unk160[temp_r28][0], temp_r31->unk160[temp_r28][1], temp_r31->unk160[temp_r28][2], temp_r27); + GXColor4u8(temp_r31->mess_pal[temp_r28][0], temp_r31->mess_pal[temp_r28][1], temp_r31->mess_pal[temp_r28][2], temp_r27); GXTexCoord2f32(temp_f29, temp_f28); GXPosition3f32(temp_f31 + temp_f27, temp_f30, 0.0f); - GXColor4u8(temp_r31->unk160[temp_r28][0], temp_r31->unk160[temp_r28][1], temp_r31->unk160[temp_r28][2], temp_r27); + GXColor4u8(temp_r31->mess_pal[temp_r28][0], temp_r31->mess_pal[temp_r28][1], temp_r31->mess_pal[temp_r28][2], temp_r27); GXTexCoord2f32(temp_f26, temp_f28); GXPosition3f32(temp_f31 + temp_f27, temp_f30 + 24.0f, 0.0f); - GXColor4u8(temp_r31->unk160[temp_r28][0], temp_r31->unk160[temp_r28][1], temp_r31->unk160[temp_r28][2], temp_r27); + GXColor4u8(temp_r31->mess_pal[temp_r28][0], temp_r31->mess_pal[temp_r28][1], temp_r31->mess_pal[temp_r28][2], temp_r27); GXTexCoord2f32(temp_f26, temp_f25); GXPosition3f32(temp_f31 + 1.0f, temp_f30 + 24.0f, 0.0f); - GXColor4u8(temp_r31->unk160[temp_r28][0], temp_r31->unk160[temp_r28][1], temp_r31->unk160[temp_r28][2], temp_r27); + GXColor4u8(temp_r31->mess_pal[temp_r28][0], temp_r31->mess_pal[temp_r28][1], temp_r31->mess_pal[temp_r28][2], temp_r27); GXTexCoord2f32(temp_f29, temp_f25); } GXEnd(); @@ -513,7 +521,7 @@ static u8 winBGMake(AnimData* arg0, AnimData* arg1) { temp_r23 = arg0->bmp->sizeY; temp_r27 = (temp_r28 + 7) & 0xF8; temp_r22 = (temp_r23 + 3) & 0xFC; - temp_r3 = arg0->bmp->data = HuMemDirectMallocNum(HEAP_SYSTEM, temp_r27 * temp_r22, 0x10000000); + temp_r3 = arg0->bmp->data = HuMemDirectMallocNum(HEAP_SYSTEM, temp_r27 * temp_r22, MEMORY_DEFAULT_NUM); for (var_r30 = 0; var_r30 < temp_r23; var_r30++) { if (var_r30 == 0) { for (var_r31 = 0; var_r31 < temp_r28; var_r31++) { @@ -568,8 +576,8 @@ static void HuWinProc(void) { HuPrcVSleep(); var_r31 = winData; for (var_r30 = 0; var_r30 < 32; var_r30++, var_r31++) { - if (var_r31->unk04 != -1 && !(var_r31->unk4C & 8)) { - switch (var_r31->unk00) { + if (var_r31->group != -1 && !(var_r31->attr & 8)) { + switch (var_r31->stat) { case 0: break; case 1: @@ -580,8 +588,8 @@ static void HuWinProc(void) { HuWinKeyWait(var_r30); break; case 3: - if (!(var_r31->unk4C & 0x40) || HuWinActiveKeyGetX(var_r31) == 0) { - var_r31->unk4C &= ~0x40; + if (!(var_r31->attr & 0x40) || HuWinActiveKeyGetX(var_r31) == 0) { + var_r31->attr &= ~0x40; HuWinComKeyGet(var_r30, winKey); HuWinChoice(var_r31); } @@ -592,25 +600,25 @@ static void HuWinProc(void) { } } -static inline void HuWinDrawMesInlineFunc(s16 arg0, s16 arg1, s16 arg2, s16 arg3, s16 arg4) { +static inline void charEntry(s16 arg0, s16 arg1, s16 arg2, s16 arg3, s16 arg4) { SomeWindowStruct* temp_r28 = &winData[arg0]; - UnknownWindowStruct1* temp_r20 = temp_r28->unk84; + WinChar *temp_r20 = temp_r28->char_data; - temp_r20 = &temp_r28->unk84[temp_r28->unk80]; - temp_r20->unk02 = arg1 - temp_r28->unk68 / 2; - temp_r20->unk04 = arg2 - temp_r28->unk6A / 2; - temp_r20->unk06 = arg3 - 0x30; - temp_r20->unk00 = arg4; - temp_r20->unk01 = 0; - temp_r28->unk80++; - if (temp_r28->unk80 >= temp_r28->unk82) { - temp_r28->unk80 = temp_r28->unk82 - 1; + temp_r20 = &temp_r28->char_data[temp_r28->num_chars]; + temp_r20->x = arg1 - temp_r28->w / 2; + temp_r20->y = arg2 - temp_r28->h / 2; + temp_r20->character = arg3 - 0x30; + temp_r20->color = arg4; + temp_r20->fade = 0; + temp_r28->num_chars++; + if (temp_r28->num_chars >= temp_r28->max_chars) { + temp_r28->num_chars = temp_r28->max_chars - 1; } } static void HuWinDrawMes(s16 arg0) { SomeWindowStruct* temp_r31 = &winData[arg0]; - SpriteGroupData* sp44 = &HuSprGrpData[temp_r31->unk04]; + SpriteGroupData* sp44 = &HuSprGrpData[temp_r31->group]; s16 var_r30; s16 sp34; s16 sp32; @@ -621,168 +629,168 @@ static void HuWinDrawMes(s16 arg0) { s16 sp28; s16 sp26; - temp_r31->unk44 += 3; - while (temp_r31->unk44 >= temp_r31->unk42 || (temp_r31->unk4C & 0x2000)) { - temp_r31->unk44 -= temp_r31->unk42; - if (temp_r31->unk44 < 0) { - temp_r31->unk44 = 0; + temp_r31->mess_time += 3; + while (temp_r31->mess_time >= temp_r31->speed || (temp_r31->attr & 0x2000)) { + temp_r31->mess_time -= temp_r31->speed; + if (temp_r31->mess_time < 0) { + temp_r31->mess_time = 0; } - sp32 = temp_r31->unk64 + fontWidthP[temp_r31->unk90[0]]; + sp32 = temp_r31->spacing_x + fontWidthP[temp_r31->mess[0]]; sp2C = 0; - if (temp_r31->unk90[0] != 0 && (temp_r31->unk4C & 4)) { - temp_r31->unk4C &= ~4; + if (temp_r31->mess[0] != 0 && (temp_r31->attr & 4)) { + temp_r31->attr &= ~4; _HuWinHomeClear(temp_r31); } - while (temp_r31->unk90[0] < 0x30 || temp_r31->unk90[0] == 0xFF) { - switch (temp_r31->unk90[0]) { + while (temp_r31->mess[0] < 0x30 || temp_r31->mess[0] == 0xFF) { + switch (temp_r31->mess[0]) { case 0x0: - if (temp_r31->unk88 == 0) { + if (temp_r31->mess_stackptr == 0) { for (sp34 = 0; sp34 < 16; sp34++) { - temp_r31->unkDA[sp34] = 0; + temp_r31->choice_disable[sp34] = 0; } - temp_r31->unk00 = 0; - temp_r31->unk4C &= ~0x80; + temp_r31->stat = 0; + temp_r31->attr &= ~0x80; return; } - temp_r31->unk88--; - temp_r31->unk90 = temp_r31->unk94[temp_r31->unk88]; - temp_r31->unk44 = 0; + temp_r31->mess_stackptr--; + temp_r31->mess = temp_r31->mess_stack[temp_r31->mess_stackptr]; + temp_r31->mess_time = 0; break; case 0x1F: - temp_r31->unk90++; - sp2E = temp_r31->unk90[0] - 1; - if (temp_r31->unkB4[sp2E] != 0) { - temp_r31->unk94[temp_r31->unk88] = temp_r31->unk90; - temp_r31->unk90 = temp_r31->unkB4[sp2E]; - temp_r31->unk88++; - if (temp_r31->unk90[0] != 0xB) { - temp_r31->unk90--; + temp_r31->mess++; + sp2E = temp_r31->mess[0] - 1; + if (temp_r31->insert_mess[sp2E] != 0) { + temp_r31->mess_stack[temp_r31->mess_stackptr] = temp_r31->mess; + temp_r31->mess = temp_r31->insert_mess[sp2E]; + temp_r31->mess_stackptr++; + if (temp_r31->mess[0] != 0xB) { + temp_r31->mess--; } } break; case 0xB: - temp_r31->unk4C &= ~0x2200; + temp_r31->attr &= ~0x2200; _HuWinHomeClear(temp_r31); - if (temp_r31->unk4C & 0x800) { - sp26 = GetMesMaxSizeSub2(temp_r31, temp_r31->unk90 + 1); - temp_r31->unk5C = (temp_r31->unk56 - sp26) / 2; - } else if (temp_r31->unk4C & 0x1000) { - sp26 = GetMesMaxSizeSub2(temp_r31, temp_r31->unk90 + 1); - temp_r31->unk5C = temp_r31->unk56 - sp26; + if (temp_r31->attr & 0x800) { + sp26 = GetMesMaxSizeSub2(temp_r31, temp_r31->mess + 1); + temp_r31->mess_x = (temp_r31->mess_rect_w - sp26) / 2; + } else if (temp_r31->attr & 0x1000) { + sp26 = GetMesMaxSizeSub2(temp_r31, temp_r31->mess + 1); + temp_r31->mess_x = temp_r31->mess_rect_w - sp26; } break; case 0x1E: - temp_r31->unk90++; - if (!(temp_r31->unk4C & 0x80)) { - temp_r31->unk60 = temp_r31->unk90[0] - 1; + temp_r31->mess++; + if (!(temp_r31->attr & 0x80)) { + temp_r31->mess_color = temp_r31->mess[0] - 1; } break; case 0x1D: - temp_r31->unk4C ^= 1; + temp_r31->attr ^= 1; break; case 0xA: - temp_r31->unk4C &= ~0x2020; - if (temp_r31->unk4C & 0x200) { - if (!(temp_r31->unk4C & 0x100)) { + temp_r31->attr &= ~0x2020; + if (temp_r31->attr & 0x200) { + if (!(temp_r31->attr & 0x100)) { if (HuWinCR(temp_r31) != 0) { - temp_r31->unk90++; + temp_r31->mess++; HuWinKeyWaitEntry(arg0); - temp_r31->unk4C |= 2; + temp_r31->attr |= 2; return; } - if (temp_r31->unk4C & 0x800) { - sp26 = GetMesMaxSizeSub2(temp_r31, temp_r31->unk90 + 1); - temp_r31->unk5C = (temp_r31->unk56 - sp26) / 2; - } else if (temp_r31->unk4C & 0x1000) { - sp26 = GetMesMaxSizeSub2(temp_r31, temp_r31->unk90 + 1); - temp_r31->unk5C = temp_r31->unk56 - sp26; + if (temp_r31->attr & 0x800) { + sp26 = GetMesMaxSizeSub2(temp_r31, temp_r31->mess + 1); + temp_r31->mess_x = (temp_r31->mess_rect_w - sp26) / 2; + } else if (temp_r31->attr & 0x1000) { + sp26 = GetMesMaxSizeSub2(temp_r31, temp_r31->mess + 1); + temp_r31->mess_x = temp_r31->mess_rect_w - sp26; } break; } - sp32 = fontWidthP[16] + temp_r31->unk64; + sp32 = fontWidthP[16] + temp_r31->spacing_x; /* fallthrough */ case 0x10: case 0x20: - temp_r31->unk4C |= 0x200; - if (temp_r31->unk5C + sp32 > temp_r31->unk56) { + temp_r31->attr |= 0x200; + if (temp_r31->mess_x + sp32 > temp_r31->mess_rect_w) { if (HuWinCR(temp_r31) != 0) { - temp_r31->unk90++; + temp_r31->mess++; HuWinKeyWaitEntry(arg0); - temp_r31->unk4C |= 2; + temp_r31->attr |= 2; return; } break; } - temp_r31->unk5C += sp32; + temp_r31->mess_x += sp32; } break; case 0xE: - temp_r31->unk4C |= 0x200; - temp_r31->unk90++; - sp30 = temp_r31->unk64 + spcFontTbl[temp_r31->unk90[0] - 1].unk06; - if (temp_r31->unk5C + sp30 > temp_r31->unk56 && HuWinCR(temp_r31) != 0) { - temp_r31->unk90--; + temp_r31->attr |= 0x200; + temp_r31->mess++; + sp30 = temp_r31->spacing_x + spcFontTbl[temp_r31->mess[0] - 1].w; + if (temp_r31->mess_x + sp30 > temp_r31->mess_rect_w && HuWinCR(temp_r31) != 0) { + temp_r31->mess--; HuWinKeyWaitEntry(arg0); - temp_r31->unk4C |= 2; + temp_r31->attr |= 2; return; } - HuWinSpcFontEntry(temp_r31, temp_r31->unk90[0] - 1, temp_r31->unk54 + temp_r31->unk5C, temp_r31->unk58 + temp_r31->unk5E); - temp_r31->unk5C += sp30; + HuWinSpcFontEntry(temp_r31, temp_r31->mess[0] - 1, temp_r31->mess_rect_x + temp_r31->mess_x, temp_r31->mess_rect_y + temp_r31->mess_y); + temp_r31->mess_x += sp30; sp2C = 1; break; case 0x1C: - temp_r31->unk90++; - HuAudFXPlay(winVoiceTbl[temp_r31->unk90[0] - 1]); + temp_r31->mess++; + HuAudFXPlay(winVoiceTbl[temp_r31->mess[0] - 1]); break; case 0xFF: - temp_r31->unk90++; + temp_r31->mess++; HuWinKeyWaitEntry(arg0); - temp_r31->unk4C |= 4; - temp_r31->unk4C &= ~0x200; + temp_r31->attr |= 4; + temp_r31->attr &= ~0x200; return; case 0xF: - temp_r31->unk4C |= 0x2000; - if (temp_r31->unkDA[temp_r31->unkD4] != 0) { - temp_r31->unk4C |= 0x20; - temp_r31->unkEA[temp_r31->unkD4].unk00 |= 1; + temp_r31->attr |= 0x2000; + if (temp_r31->choice_disable[temp_r31->num_choices] != 0) { + temp_r31->attr |= 0x20; + temp_r31->choice_data[temp_r31->num_choices].stat |= 1; } else { - temp_r31->unkEA[temp_r31->unkD4].unk00 &= ~1; + temp_r31->choice_data[temp_r31->num_choices].stat &= ~1; } - temp_r31->unkEA[temp_r31->unkD4].unk02 = temp_r31->unk5C + temp_r31->unk58; - temp_r31->unkEA[temp_r31->unkD4].unk04 = temp_r31->unk5E + temp_r31->unk54; - temp_r31->unkD4++; + temp_r31->choice_data[temp_r31->num_choices].x = temp_r31->mess_x + temp_r31->mess_rect_y; + temp_r31->choice_data[temp_r31->num_choices].y = temp_r31->mess_y + temp_r31->mess_rect_x; + temp_r31->num_choices++; break; case 0xC: - temp_r31->unk4C |= 0x200; - sp30 = temp_r31->unk152 * ((temp_r31->unk5C + temp_r31->unk152) / temp_r31->unk152) - temp_r31->unk5C; - if (temp_r31->unk5C + sp30 > temp_r31->unk56) { + temp_r31->attr |= 0x200; + sp30 = temp_r31->char_w * ((temp_r31->mess_x + temp_r31->char_w) / temp_r31->char_w) - temp_r31->mess_x; + if (temp_r31->mess_x + sp30 > temp_r31->mess_rect_w) { if (HuWinCR(temp_r31) != 0) { - temp_r31->unk90++; + temp_r31->mess++; HuWinKeyWaitEntry(arg0); - temp_r31->unk4C |= 2; + temp_r31->attr |= 2; return; } } else { - temp_r31->unk5C += sp30; + temp_r31->mess_x += sp30; } break; } - temp_r31->unk90++; - sp32 = temp_r31->unk64 + fontWidthP[temp_r31->unk90[0]]; + temp_r31->mess++; + sp32 = temp_r31->spacing_x + fontWidthP[temp_r31->mess[0]]; if (sp2C != 0) { break; } } if (sp2C == 0) { - if (temp_r31->unk5C + sp32 > temp_r31->unk56 && HuWinCR(temp_r31) != 0) { + if (temp_r31->mess_x + sp32 > temp_r31->mess_rect_w && HuWinCR(temp_r31) != 0) { HuWinKeyWaitEntry(arg0); - temp_r31->unk4C |= 2; + temp_r31->attr |= 2; return; } - var_r30 = temp_r31->unk90[0]; - temp_r31->unk4C |= 0x200; - if (temp_r31->unk90[1] == 0x80) { + var_r30 = temp_r31->mess[0]; + temp_r31->attr |= 0x200; + if (temp_r31->mess[1] == 0x80) { if (var_r30 >= 0x96 && var_r30 <= 0xA4) { var_r30 = var_r30 + 0x6A; } else if (var_r30 >= 0xAA && var_r30 <= 0xAE) { @@ -792,44 +800,44 @@ static void HuWinDrawMes(s16 arg0) { } else if (var_r30 >= 0xEA && var_r30 <= 0xEE) { var_r30 = var_r30 + 0x3E; } - temp_r31->unk90++; - } else if (temp_r31->unk90[1] == 0x81) { + temp_r31->mess++; + } else if (temp_r31->mess[1] == 0x81) { if (var_r30 >= 0xAA && var_r30 <= 0xAE) { var_r30 = (var_r30 + 0x6A); } else if (var_r30 >= 0xEA && var_r30 <= 0xEE) { var_r30 = (var_r30 + 0x43); } - temp_r31->unk90++; + temp_r31->mess++; } - sp28 = (temp_r31->unk4C & 0x20) ? 8 : temp_r31->unk60; - if (temp_r31->unk4C & 1) { + sp28 = (temp_r31->attr & 0x20) ? 8 : temp_r31->mess_color; + if (temp_r31->attr & 1) { sp2A = 0; - if (temp_r31->unk60 == 0 || temp_r31->unk60 == 1) { + if (temp_r31->mess_color == 0 || temp_r31->mess_color == 1) { sp2A = 8; } - HuWinDrawMesInlineFunc(arg0, temp_r31->unk54 + temp_r31->unk5C + 2, temp_r31->unk58 + temp_r31->unk5E , var_r30, sp2A); - HuWinDrawMesInlineFunc(arg0, temp_r31->unk54 + temp_r31->unk5C - 2, temp_r31->unk58 + temp_r31->unk5E , var_r30, sp2A); - HuWinDrawMesInlineFunc(arg0, temp_r31->unk54 + temp_r31->unk5C , temp_r31->unk58 + temp_r31->unk5E + 2, var_r30, sp2A); - HuWinDrawMesInlineFunc(arg0, temp_r31->unk54 + temp_r31->unk5C , temp_r31->unk58 + temp_r31->unk5E - 2, var_r30, sp2A); - HuWinDrawMesInlineFunc(arg0, temp_r31->unk54 + temp_r31->unk5C , temp_r31->unk58 + temp_r31->unk5E , var_r30, sp28); + charEntry(arg0, temp_r31->mess_rect_x + temp_r31->mess_x + 2, temp_r31->mess_rect_y + temp_r31->mess_y , var_r30, sp2A); + charEntry(arg0, temp_r31->mess_rect_x + temp_r31->mess_x - 2, temp_r31->mess_rect_y + temp_r31->mess_y , var_r30, sp2A); + charEntry(arg0, temp_r31->mess_rect_x + temp_r31->mess_x , temp_r31->mess_rect_y + temp_r31->mess_y + 2, var_r30, sp2A); + charEntry(arg0, temp_r31->mess_rect_x + temp_r31->mess_x , temp_r31->mess_rect_y + temp_r31->mess_y - 2, var_r30, sp2A); + charEntry(arg0, temp_r31->mess_rect_x + temp_r31->mess_x , temp_r31->mess_rect_y + temp_r31->mess_y , var_r30, sp28); } else { - HuWinDrawMesInlineFunc(arg0, temp_r31->unk54 + temp_r31->unk5C + 2, temp_r31->unk58 + temp_r31->unk5E + 2, var_r30, temp_r31->unk62); - HuWinDrawMesInlineFunc(arg0, temp_r31->unk54 + temp_r31->unk5C , temp_r31->unk58 + temp_r31->unk5E , var_r30, sp28); + charEntry(arg0, temp_r31->mess_rect_x + temp_r31->mess_x + 2, temp_r31->mess_rect_y + temp_r31->mess_y + 2, var_r30, temp_r31->mess_shadow_color); + charEntry(arg0, temp_r31->mess_rect_x + temp_r31->mess_x , temp_r31->mess_rect_y + temp_r31->mess_y , var_r30, sp28); } - temp_r31->unk5C += sp32; - temp_r31->unk90++; + temp_r31->mess_x += sp32; + temp_r31->mess++; } } } static s32 HuWinCR(SomeWindowStruct* arg0) { - if (arg0->unk5E + 0x30 > arg0->unk5A) { - arg0->unk5E = 0; - arg0->unk5C = 0; + if (arg0->mess_y + 0x30 > arg0->mess_rect_h) { + arg0->mess_y = 0; + arg0->mess_x = 0; return 1; } else { - arg0->unk5E += arg0->unk66 + 0x18; - arg0->unk5C = 0; + arg0->mess_y += arg0->spacing_y + 0x18; + arg0->mess_x = 0; return 0; } } @@ -837,13 +845,13 @@ static s32 HuWinCR(SomeWindowStruct* arg0) { static void _HuWinHomeClear(SomeWindowStruct* arg0) { s16 var_r30; - arg0->unk80 = 0; - arg0->unk5E = arg0->unk5C = 0; - arg0->unkD4 = 0; + arg0->num_chars = 0; + arg0->mess_y = arg0->mess_x = 0; + arg0->num_choices = 0; HuWinSpcFontClear(arg0); - arg0->unk4C &= ~0x2020; + arg0->attr &= ~0x2020; for (var_r30 = 0; var_r30 < 16; var_r30++) { - arg0->unkEA[var_r30].unk00 = 0; + arg0->choice_data[var_r30].stat = 0; } } @@ -856,66 +864,67 @@ void HuWinHomeClear(s16 arg0) { void HuWinKeyWaitEntry(s16 arg0) { SomeWindowStruct* temp_r31 = &winData[arg0]; - if (temp_r31->unk4C & 0x400) { - temp_r31->unk00 = 0; + if (temp_r31->attr & 0x400) { + temp_r31->stat = 0; } else { - temp_r31->unk00 = 2; - temp_r31->unk46 = HuWinSpcFontEntry(temp_r31, 0x13, temp_r31->unk56 - 0x14, temp_r31->unk5A - 0x18); + temp_r31->stat = 2; + temp_r31->advance_sprite = HuWinSpcFontEntry(temp_r31, 19, temp_r31->mess_rect_w - 20, temp_r31->mess_rect_h - 24); } } static void HuWinKeyWait(s16 arg0) { SomeWindowStruct* temp_r31 = &winData[arg0]; - if (temp_r31->unk154 & HuWinActivePadGet(temp_r31)) { - temp_r31->unk156 = HuWinActivePadGet(temp_r31); - temp_r31->unk00 = 1; - HuAudFXPlay(0x1C); - HuWinSprKill(arg0, temp_r31->unk46); - if (temp_r31->unk4C & 2) { + if (temp_r31->push_key & HuWinActivePadGet(temp_r31)) { + temp_r31->key_down = HuWinActivePadGet(temp_r31); + temp_r31->stat = 1; + HuAudFXPlay(28); + HuWinSprKill(arg0, temp_r31->advance_sprite); + if (temp_r31->attr & 2) { _HuWinHomeClear(temp_r31); } - temp_r31->unk4C &= ~2; + temp_r31->attr &= ~2; } } static s16 HuWinSpcFontEntry(SomeWindowStruct* arg0, s16 arg1, s16 arg2, s16 arg3) { - SpriteGroupData* spC = &HuSprGrpData[arg0->unk04]; + SpriteGroupData* spC = &HuSprGrpData[arg0->group]; s16 temp_r3; s16 var_r30; - AnimData* temp_r27; + AnimData *anim; for (var_r30 = 10; var_r30 < 30; var_r30++) { - if (arg0->unk06[var_r30] == -1) { - temp_r27 = *spcFontTbl[arg1].unk00; - arg0->unk06[var_r30] = temp_r3 = HuSprCreate(temp_r27, arg0->unk48 - 1, spcFontTbl[arg1].unk04); - HuSprGrpMemberSet(arg0->unk04, var_r30, temp_r3); - HuSprPosSet(arg0->unk04, var_r30, arg2 + spcFontTbl[arg1].unk0A - arg0->unk68 / 2, arg3 + spcFontTbl[arg1].unk0C - arg0->unk6A / 2); + if (arg0->sprite_id[var_r30] == -1) { + anim = *spcFontTbl[arg1].anim; + arg0->sprite_id[var_r30] = temp_r3 = HuSprCreate(anim, arg0->prio - 1, spcFontTbl[arg1].bank); + HuSprGrpMemberSet(arg0->group, var_r30, temp_r3); + HuSprPosSet(arg0->group, var_r30, arg2 + spcFontTbl[arg1].center_x - arg0->w / 2, arg3 + spcFontTbl[arg1].center_y - arg0->h / 2); break; } } return var_r30; } +static void HuWinSpcFontPosSet(SomeWindowStruct* arg0, s16 arg1, s16 arg2, s16 arg3) { + SpriteGroupData* temp_var = &HuSprGrpData[arg0->group]; + + HuSprPosSet(arg0->group, arg1, arg2 - arg0->w / 2, arg3 - arg0->h / 2); +} + static void HuWinSpcFontClear(SomeWindowStruct* arg0) { s16 var_r31; for (var_r31 = 10; var_r31 < 30; var_r31++) { - if (arg0->unk06[var_r31] != -1) { - HuSprGrpMemberKill(arg0->unk04, var_r31); - arg0->unk06[var_r31] = -1; + if (arg0->sprite_id[var_r31] != -1) { + HuSprGrpMemberKill(arg0->group, var_r31); + arg0->sprite_id[var_r31] = -1; } } } -static inline void HuWinChoiceInlineFunction(SomeWindowStruct* arg0, s16 arg1, s16 arg2, s16 arg3) { - SpriteGroupData* temp_var = &HuSprGrpData[arg0->unk04]; - - HuSprPosSet(arg0->unk04, arg1, arg2 - arg0->unk68 / 2, arg3 - arg0->unk6A / 2); -} void HuWinChoice(SomeWindowStruct* arg0) { - UnknownWindowStruct2* var_r31; + WinChoice *var_r31; f32 var_f30; f32 var_f31; s16 temp_r20; @@ -930,7 +939,7 @@ void HuWinChoice(SomeWindowStruct* arg0) { s16 var_r23; s16 var_r30; - temp_r26 = arg0->unkD6; + temp_r26 = arg0->choice; var_r23 = temp_r26; var_r19 = -1; temp_r21 = HuWinActivePadGet(arg0); @@ -946,42 +955,42 @@ void HuWinChoice(SomeWindowStruct* arg0) { if (temp_r21 & 4) { var_r19 = 3; } - temp_r25 = arg0->unkEA[temp_r26].unk02; - temp_r24 = arg0->unkEA[temp_r26].unk04; + temp_r25 = arg0->choice_data[temp_r26].x; + temp_r24 = arg0->choice_data[temp_r26].y; var_f31 = 100000.0f; var_f30 = var_f31; - temp_r27 = arg0->unkD4; + temp_r27 = arg0->num_choices; switch (var_r19) { case 0: - for (var_r30 = 0, var_r31 = arg0->unkEA; var_r30 < temp_r27; var_r30++, var_r31++) { - if (var_r30 != temp_r26 && !(var_r31->unk00 & 1) && var_r31->unk04 == temp_r24 && var_r31->unk02 < temp_r25) { + for (var_r30 = 0, var_r31 = arg0->choice_data; var_r30 < temp_r27; var_r30++, var_r31++) { + if (var_r30 != temp_r26 && !(var_r31->stat & 1) && var_r31->y == temp_r24 && var_r31->x < temp_r25) { break; } } if (var_r30 != temp_r27) { - for (var_r30 = 0, var_r31 = arg0->unkEA; var_r30 < temp_r27; var_r30++, var_r31++) { - if (var_r30 != temp_r26 && !(var_r31->unk00 & 1) && var_r31->unk04 == temp_r24 && var_r31->unk02 < temp_r25 && var_f30 > temp_r25 - var_r31->unk02) { - var_f30 = temp_r25 - var_r31->unk02; + for (var_r30 = 0, var_r31 = arg0->choice_data; var_r30 < temp_r27; var_r30++, var_r31++) { + if (var_r30 != temp_r26 && !(var_r31->stat & 1) && var_r31->y == temp_r24 && var_r31->x < temp_r25 && var_f30 > temp_r25 - var_r31->x) { + var_f30 = temp_r25 - var_r31->x; var_r23 = var_r30; } } } break; case 1: - for (var_r30 = 0, var_r31 = arg0->unkEA; var_r30 < temp_r27; var_r30++, var_r31++) { - if (var_r30 != temp_r26 && !(var_r31->unk00 & 1) && var_r31->unk04 < temp_r24) { + for (var_r30 = 0, var_r31 = arg0->choice_data; var_r30 < temp_r27; var_r30++, var_r31++) { + if (var_r30 != temp_r26 && !(var_r31->stat & 1) && var_r31->y < temp_r24) { break; } } if (var_r30 != temp_r27) { - for (var_r30 = 0, var_r31 = arg0->unkEA; var_r30 < temp_r27; var_r30++, var_r31++) { - if (var_r30 != temp_r26 && !(var_r31->unk00 & 1) && var_r31->unk04 < temp_r24) { - temp_r20 = temp_r24 - var_r31->unk04; + for (var_r30 = 0, var_r31 = arg0->choice_data; var_r30 < temp_r27; var_r30++, var_r31++) { + if (var_r30 != temp_r26 && !(var_r31->stat & 1) && var_r31->y < temp_r24) { + temp_r20 = temp_r24 - var_r31->y; if (temp_r20 <= var_f30) { if (temp_r20 < var_f30) { var_f31 = 100000.0f; } - temp_r28 = temp_r25 - var_r31->unk02; + temp_r28 = temp_r25 - var_r31->x; temp_r28 = temp_r28 * temp_r28; if (temp_r28 < var_f31) { var_f30 = temp_r20; @@ -993,16 +1002,16 @@ void HuWinChoice(SomeWindowStruct* arg0) { } } else { var_r22 = -1000; - for (var_r30 = 0, var_r31 = arg0->unkEA; var_r30 < temp_r27; var_r30++, var_r31++) { - if (var_r30 != temp_r26 && !(var_r31->unk00 & 1) && var_r31->unk04 > var_r22) { - var_r22 = var_r31->unk04; + for (var_r30 = 0, var_r31 = arg0->choice_data; var_r30 < temp_r27; var_r30++, var_r31++) { + if (var_r30 != temp_r26 && !(var_r31->stat & 1) && var_r31->y > var_r22) { + var_r22 = var_r31->y; } } if (var_r22 != temp_r24) { var_f31 = 100000.0f; - for (var_r30 = 0, var_r31 = arg0->unkEA; var_r30 < temp_r27; var_r30++, var_r31++) { - if (var_r30 != temp_r26 && !(var_r31->unk00 & 1) && var_r31->unk04 == var_r22) { - temp_r28 = temp_r25 - var_r31->unk02; + for (var_r30 = 0, var_r31 = arg0->choice_data; var_r30 < temp_r27; var_r30++, var_r31++) { + if (var_r30 != temp_r26 && !(var_r31->stat & 1) && var_r31->y == var_r22) { + temp_r28 = temp_r25 - var_r31->x; temp_r28 = temp_r28 * temp_r28; if (temp_r28 < var_f31) { var_f31 = temp_r28; @@ -1014,35 +1023,35 @@ void HuWinChoice(SomeWindowStruct* arg0) { } break; case 2: - for (var_r30 = 0, var_r31 = arg0->unkEA; var_r30 < temp_r27; var_r30++, var_r31++) { - if (var_r30 != temp_r26 && !(var_r31->unk00 & 1) && var_r31->unk04 == temp_r24 && var_r31->unk02 > temp_r25) { + for (var_r30 = 0, var_r31 = arg0->choice_data; var_r30 < temp_r27; var_r30++, var_r31++) { + if (var_r30 != temp_r26 && !(var_r31->stat & 1) && var_r31->y == temp_r24 && var_r31->x > temp_r25) { break; } } if (var_r30 != temp_r27) { - for (var_r30 = 0, var_r31 = arg0->unkEA; var_r30 < temp_r27; var_r30++, var_r31++) { - if (var_r30 != temp_r26 && !(var_r31->unk00 & 1) && var_r31->unk04 == temp_r24 && var_r31->unk02 > temp_r25 && var_f30 > var_r31->unk02 - temp_r25) { - var_f30 = var_r31->unk02 - temp_r25; + for (var_r30 = 0, var_r31 = arg0->choice_data; var_r30 < temp_r27; var_r30++, var_r31++) { + if (var_r30 != temp_r26 && !(var_r31->stat & 1) && var_r31->y == temp_r24 && var_r31->x > temp_r25 && var_f30 > var_r31->x - temp_r25) { + var_f30 = var_r31->x - temp_r25; var_r23 = var_r30; } } } break; case 3: - for (var_r30 = 0, var_r31 = arg0->unkEA; var_r30 < temp_r27; var_r30++, var_r31++) { - if (var_r30 != temp_r26 && !(var_r31->unk00 & 1) && var_r31->unk04 > temp_r24) { + for (var_r30 = 0, var_r31 = arg0->choice_data; var_r30 < temp_r27; var_r30++, var_r31++) { + if (var_r30 != temp_r26 && !(var_r31->stat & 1) && var_r31->y > temp_r24) { break; } } if (var_r30 != temp_r27) { - for (var_r30 = 0, var_r31 = arg0->unkEA; var_r30 < temp_r27; var_r30++, var_r31++) { - if (var_r30 != temp_r26 && !(var_r31->unk00 & 1) && var_r31->unk04 > temp_r24) { - temp_r20 = var_r31->unk04 - temp_r24; + for (var_r30 = 0, var_r31 = arg0->choice_data; var_r30 < temp_r27; var_r30++, var_r31++) { + if (var_r30 != temp_r26 && !(var_r31->stat & 1) && var_r31->y > temp_r24) { + temp_r20 = var_r31->y - temp_r24; if (temp_r20 <= var_f30) { if (temp_r20 < var_f30) { var_f31 = 100000.0f; } - temp_r28 = temp_r25 - var_r31->unk02; + temp_r28 = temp_r25 - var_r31->x; temp_r28 = temp_r28 * temp_r28; if (temp_r28 < var_f31) { var_f30 = temp_r20; @@ -1054,16 +1063,16 @@ void HuWinChoice(SomeWindowStruct* arg0) { } } else { var_r22 = 1000; - for (var_r30 = 0, var_r31 = arg0->unkEA; var_r30 < temp_r27; var_r30++, var_r31++) { - if (var_r30 != temp_r26 && !(var_r31->unk00 & 1) && var_r31->unk04 < var_r22) { - var_r22 = var_r31->unk04; + for (var_r30 = 0, var_r31 = arg0->choice_data; var_r30 < temp_r27; var_r30++, var_r31++) { + if (var_r30 != temp_r26 && !(var_r31->stat & 1) && var_r31->y < var_r22) { + var_r22 = var_r31->y; } } if (var_r22 != temp_r24) { var_f31 = 100000.0f; - for (var_r30 = 0, var_r31 = arg0->unkEA; var_r30 < temp_r27; var_r30++, var_r31++) { - if (var_r30 != temp_r26 && !(var_r31->unk00 & 1) && var_r31->unk04 == var_r22) { - temp_r28 = temp_r25 - var_r31->unk02; + for (var_r30 = 0, var_r31 = arg0->choice_data; var_r30 < temp_r27; var_r30++, var_r31++) { + if (var_r30 != temp_r26 && !(var_r31->stat & 1) && var_r31->y == var_r22) { + temp_r28 = temp_r25 - var_r31->x; temp_r28 = temp_r28 * temp_r28; if (temp_r28 < var_f31) { var_f31 = temp_r28; @@ -1075,20 +1084,20 @@ void HuWinChoice(SomeWindowStruct* arg0) { } break; } - if (arg0->unkD6 != var_r23) { - arg0->unkD6 = var_r23; + if (arg0->choice != var_r23) { + arg0->choice = var_r23; HuAudFXPlay(0); - } else if (temp_r21 & (arg0->unk158 | 0x100)) { + } else if (temp_r21 & (arg0->key_auto | 0x100)) { HuAudFXPlay(2); - arg0->unk156 = temp_r21; - arg0->unk00 = 0; - } else if ((temp_r21 & 0x200) && !(arg0->unk4C & 0x10)) { + arg0->key_down = temp_r21; + arg0->stat = 0; + } else if ((temp_r21 & 0x200) && !(arg0->attr & 0x10)) { HuAudFXPlay(3); - arg0->unk156 = temp_r21; - arg0->unkD6 = -1; - arg0->unk00 = 0; + arg0->key_down = temp_r21; + arg0->choice = -1; + arg0->stat = 0; } - HuWinChoiceInlineFunction(arg0, arg0->unkD8, arg0->unkEA[var_r23].unk02 + spcFontTbl[0x14].unk0A, arg0->unkEA[var_r23].unk04 + spcFontTbl[0x14].unk0C); + HuWinSpcFontPosSet(arg0, arg0->cursor_sprite, arg0->choice_data[var_r23].x + spcFontTbl[20].center_x, arg0->choice_data[var_r23].y + spcFontTbl[20].center_y); } u32 HuWinActivePadGet(SomeWindowStruct* arg0) { @@ -1097,7 +1106,7 @@ u32 HuWinActivePadGet(SomeWindowStruct* arg0) { var_r30 = 0; for (var_r31 = 0; var_r31 < 4; var_r31++) { - if (arg0->unk01 & (1 << var_r31)) { + if (arg0->active_pad & (1 << var_r31)) { var_r30 |= winKey[var_r31]; } } @@ -1111,7 +1120,7 @@ u32 HuWinActiveKeyGetX(SomeWindowStruct* arg0) { u8 temp_r28; var_r29 = 0; - temp_r28 = (arg0->unk01 & ~arg0->unk02); + temp_r28 = (arg0->active_pad & ~arg0->player_disable); for (var_r30 = 0; var_r30 < 4; var_r30++) { if (temp_r28 & (1 << var_r30)) { for (var_r31 = 0; var_r31 < 4; var_r31++) { @@ -1130,107 +1139,107 @@ u32 HuWinActiveKeyGetX(SomeWindowStruct* arg0) { void HuWinPosSet(s16 arg0, f32 arg1, f32 arg2) { SomeWindowStruct* temp_r31 = &winData[arg0]; - temp_r31->unk6C = arg1; - temp_r31->unk70 = arg2; - HuSprGrpPosSet(temp_r31->unk04, arg1, arg2); + temp_r31->pos_x = arg1; + temp_r31->pos_y = arg2; + HuSprGrpPosSet(temp_r31->group, arg1, arg2); } void HuWinScaleSet(s16 arg0, f32 arg1, f32 arg2) { SomeWindowStruct* temp_r31 = &winData[arg0]; - temp_r31->unk74 = arg1; - temp_r31->unk78 = arg2; - HuSprGrpScaleSet(temp_r31->unk04, arg1, arg2); + temp_r31->scale_x = arg1; + temp_r31->scale_y = arg2; + HuSprGrpScaleSet(temp_r31->group, arg1, arg2); } void HuWinZRotSet(s16 arg0, f32 arg1) { SomeWindowStruct* temp_r31 = &winData[arg0]; - temp_r31->unk7C = arg1; - HuSprGrpZRotSet(temp_r31->unk04, arg1); + temp_r31->rot = arg1; + HuSprGrpZRotSet(temp_r31->group, arg1); } void HuWinCenterPosSet(s16 arg0, f32 arg1, f32 arg2) { SomeWindowStruct* temp_r31 = &winData[arg0]; - HuSprGrpCenterSet(temp_r31->unk04, temp_r31->unk68 / 2.0f - arg1, temp_r31->unk6A / 2.0f - arg2); + HuSprGrpCenterSet(temp_r31->group, temp_r31->w / 2.0f - arg1, temp_r31->h / 2.0f - arg2); } void HuWinDrawNoSet(s16 arg0, s16 arg1) { SomeWindowStruct* temp_r31 = &winData[arg0]; - HuSprGrpDrawNoSet(temp_r31->unk04, arg1); + HuSprGrpDrawNoSet(temp_r31->group, arg1); } void HuWinScissorSet(s16 arg0, s16 arg1, s16 arg2, s16 arg3, s16 arg4) { SomeWindowStruct* temp_r31 = &winData[arg0]; - HuSprGrpScissorSet(temp_r31->unk04, arg1, arg2, arg3, arg4); + HuSprGrpScissorSet(temp_r31->group, arg1, arg2, arg3, arg4); } void HuWinPriSet(s16 arg0, s16 arg1) { SomeWindowStruct* temp_r31 = &winData[arg0]; s16 var_r30; - HuSprPriSet(temp_r31->unk04, 0, arg1); - HuSprPriSet(temp_r31->unk04, 1, arg1); + HuSprPriSet(temp_r31->group, 0, arg1); + HuSprPriSet(temp_r31->group, 1, arg1); for (var_r30 = 2; var_r30 < 30; var_r30++) { - if (temp_r31->unk06[var_r30] != -1) { - HuSprPriSet(temp_r31->unk04, var_r30, arg1 - 1); + if (temp_r31->sprite_id[var_r30] != -1) { + HuSprPriSet(temp_r31->group, var_r30, arg1 - 1); } } - temp_r31->unk48 = arg1; + temp_r31->prio = arg1; } void HuWinAttrSet(s16 arg0, s32 arg1) { SomeWindowStruct* temp_r31 = &winData[arg0]; - temp_r31->unk4C |= arg1; + temp_r31->attr |= arg1; } void HuWinAttrReset(s16 arg0, u32 arg1) { SomeWindowStruct* temp_r31 = &winData[arg0]; - temp_r31->unk4C &= ~arg1; + temp_r31->attr &= ~arg1; } u8 HuWinStatGet(s16 arg0) { SomeWindowStruct* temp_r31 = &winData[arg0]; - return temp_r31->unk00; + return temp_r31->stat; } void HuWinMesColSet(s16 arg0, u8 arg1) { SomeWindowStruct* temp_r31 = &winData[arg0]; - temp_r31->unk60 = arg1; - temp_r31->unk4C |= 0x80; + temp_r31->mess_color = arg1; + temp_r31->attr |= 0x80; } void HuWinMesPalSet(s16 arg0, u8 arg1, u8 arg2, u8 arg3, u8 arg4) { SomeWindowStruct* temp_r31 = &winData[arg0]; - temp_r31->unk160[arg1][0] = arg2; - temp_r31->unk160[arg1][1] = arg3; - temp_r31->unk160[arg1][2] = arg4; + temp_r31->mess_pal[arg1][0] = arg2; + temp_r31->mess_pal[arg1][1] = arg3; + temp_r31->mess_pal[arg1][2] = arg4; } void HuWinBGTPLvlSet(s16 arg0, f32 arg1) { SomeWindowStruct* temp_r31 = &winData[arg0]; - HuSprTPLvlSet(temp_r31->unk04, 0, arg1); + HuSprTPLvlSet(temp_r31->group, 0, arg1); } -void HuWinBGColSet(s16 arg0, ColorRGB* arg1) { +void HuWinBGColSet(s16 arg0, GXColor *arg1) { SomeWindowStruct* temp_r31 = &winData[arg0]; - HuSprColorSet(temp_r31->unk04, 0, arg1->r, arg1->g, arg1->b); + HuSprColorSet(temp_r31->group, 0, arg1->r, arg1->g, arg1->b); } void HuWinMesSpeedSet(s16 arg0, s16 arg1) { SomeWindowStruct* temp_r31 = &winData[arg0]; - temp_r31->unk42 = arg1; + temp_r31->speed = arg1; } void HuWinMesRead(s32 arg0) { @@ -1255,24 +1264,24 @@ void HuWinMesRead(s32 arg0) { void HuWinMesSet(s16 arg0, u32 arg1) { SomeWindowStruct* win = &winData[arg0]; - win->unk00 = 1; + win->stat = 1; if ((arg1 & 0x80000000) == 0) { if (messDataPtr == 0) { OSReport("Error: No Message\n"); return; } - win->unk90 = MessData_MesPtrGet(messDataPtr, arg1); - if (win->unk90 == 0) { + win->mess = MessData_MesPtrGet(messDataPtr, arg1); + if (win->mess == 0) { OSReport("Error: No Message data\n"); HuWinMesSet(arg0, 0); return; } } else { - win->unk90 = (u8*) arg1; + win->mess = (u8*) arg1; } - if (!(win->unk4C & 0x80)) { - win->unk60 = 7; - win->unk44 = 0; + if (!(win->attr & 0x80)) { + win->mess_color = 7; + win->mess_time = 0; } } @@ -1284,63 +1293,63 @@ void HuWinInsertMesSet(s16 arg0, u32 arg1, s16 arg2) { OSReport("Error: No Message\n"); return; } - temp_r31->unkB4[arg2] = MessData_MesPtrGet(messDataPtr, arg1); - if (temp_r31->unkB4[arg2] == 0) { + temp_r31->insert_mess[arg2] = MessData_MesPtrGet(messDataPtr, arg1); + if (temp_r31->insert_mess[arg2] == 0) { OSReport("Error: No Message data\n"); } } else { - temp_r31->unkB4[arg2] = (void*) arg1; + temp_r31->insert_mess[arg2] = (void*) arg1; } } s16 HuWinChoiceGet(s16 arg0, s16 arg1) { SomeWindowStruct* temp_r31 = &winData[arg0]; - temp_r31->unk4C |= 0x40; - while (temp_r31->unk00 != 0) { + temp_r31->attr |= 0x40; + while (temp_r31->stat != 0) { HuPrcVSleep(); } - for (; arg1 < temp_r31->unkD4; arg1++) { - if (!(temp_r31->unkEA[arg1].unk00 & 1)) { + for (; arg1 < temp_r31->num_choices; arg1++) { + if (!(temp_r31->choice_data[arg1].stat & 1)) { break; } } - if (arg1 == temp_r31->unkD4) { - for (arg1 = 0; arg1 < temp_r31->unkD4; arg1++) { - if (!(temp_r31->unkEA[arg1].unk00 & 1)) { + if (arg1 == temp_r31->num_choices) { + for (arg1 = 0; arg1 < temp_r31->num_choices; arg1++) { + if (!(temp_r31->choice_data[arg1].stat & 1)) { break; } } - if (arg1 == temp_r31->unkD4) { + if (arg1 == temp_r31->num_choices) { return -1; } } - temp_r31->unkD8 = HuWinSpcFontEntry(temp_r31, 0x14, temp_r31->unkEA[arg1].unk02, temp_r31->unkEA[arg1].unk04); - temp_r31->unk00 = 3; - temp_r31->unkD6 = arg1; - while (temp_r31->unk00 != 0) { + temp_r31->cursor_sprite = HuWinSpcFontEntry(temp_r31, 0x14, temp_r31->choice_data[arg1].x, temp_r31->choice_data[arg1].y); + temp_r31->stat = 3; + temp_r31->choice = arg1; + while (temp_r31->stat != 0) { HuPrcVSleep(); } - return temp_r31->unkD6; + return temp_r31->choice; } s16 HuWinChoiceNumGet(s16 arg0) { SomeWindowStruct* temp_r31 = &winData[arg0]; - return temp_r31->unkD4; + return temp_r31->num_choices; } void HuWinChoiceDisable(s16 arg0, s16 arg1) { SomeWindowStruct* temp_r31 = &winData[arg0]; - temp_r31->unkDA[arg1] = 1; + temp_r31->choice_disable[arg1] = 1; } s16 HuWinChoiceNowGet(s16 arg0) { SomeWindowStruct* temp_r31 = &winData[arg0]; - if (temp_r31->unk00 == 3) { - return temp_r31->unkD6; + if (temp_r31->stat == 3) { + return temp_r31->choice; } else { return -1; } @@ -1349,7 +1358,7 @@ s16 HuWinChoiceNowGet(s16 arg0) { void HuWinMesWait(s16 arg0) { SomeWindowStruct* temp_r31 = &winData[arg0]; - while (temp_r31->unk00 != 0) { + while (temp_r31->stat != 0) { HuPrcVSleep(); } } @@ -1358,20 +1367,20 @@ void HuWinAnimSet(s16 arg0, AnimData* arg1, s16 arg2, f32 arg3, f32 arg4) { SomeWindowStruct* temp_r31 = &winData[arg0]; s16 temp_r30; - temp_r30 = HuSprCreate(arg1, temp_r31->unk48 - 1, arg2); + temp_r30 = HuSprCreate(arg1, temp_r31->prio - 1, arg2); HuWinSprSet(arg0, temp_r30, arg3, arg4); } s16 HuWinSprSet(s16 arg0, s16 arg1, f32 arg2, f32 arg3) { SomeWindowStruct* temp_r31 = &winData[arg0]; - SpriteGroupData* temp_r29 = &HuSprGrpData[temp_r31->unk04]; + SpriteGroupData* temp_r29 = &HuSprGrpData[temp_r31->group]; s16 var_r30; for (var_r30 = 2; var_r30 <= 9; var_r30++) { - if (temp_r31->unk06[var_r30] == -1) { - temp_r31->unk06[var_r30] = arg1; - HuSprGrpMemberSet(temp_r31->unk04, var_r30, arg1); - HuSprPosSet(temp_r31->unk04, var_r30, arg2 - temp_r29->center_x, arg3 - temp_r29->center_y); + if (temp_r31->sprite_id[var_r30] == -1) { + temp_r31->sprite_id[var_r30] = arg1; + HuSprGrpMemberSet(temp_r31->group, var_r30, arg1); + HuSprPosSet(temp_r31->group, var_r30, arg2 - temp_r29->center_x, arg3 - temp_r29->center_y); break; } } @@ -1380,29 +1389,29 @@ s16 HuWinSprSet(s16 arg0, s16 arg1, f32 arg2, f32 arg3) { void HuWinSprPosSet(s16 arg0, s16 arg1, f32 arg2, f32 arg3) { SomeWindowStruct* temp_r31 = &winData[arg0]; - SpriteGroupData* temp_r30 = &HuSprGrpData[temp_r31->unk04]; + SpriteGroupData* temp_r30 = &HuSprGrpData[temp_r31->group]; - HuSprPosSet(temp_r31->unk04, arg1, arg2 - temp_r30->center_x, arg3 - temp_r30->center_y); + HuSprPosSet(temp_r31->group, arg1, arg2 - temp_r30->center_x, arg3 - temp_r30->center_y); } void HuWinSprPriSet(s16 arg0, s16 arg1, s16 arg2) { SomeWindowStruct* temp_r31 = &winData[arg0]; - SpriteGroupData* sp10 = &HuSprGrpData[temp_r31->unk04]; + SpriteGroupData* sp10 = &HuSprGrpData[temp_r31->group]; - HuSprPriSet(temp_r31->unk04, arg1, arg2); + HuSprPriSet(temp_r31->group, arg1, arg2); } s16 HuWinSprIDGet(s16 arg0, s16 arg1) { SomeWindowStruct* temp_r31 = &winData[arg0]; - return temp_r31->unk06[arg1]; + return temp_r31->sprite_id[arg1]; } void HuWinSprKill(s16 arg0, s16 arg1) { SomeWindowStruct* temp_r31 = &winData[arg0]; - HuSprGrpMemberKill(temp_r31->unk04, arg1); - temp_r31->unk06[arg1] = -1; + HuSprGrpMemberKill(temp_r31->group, arg1); + temp_r31->sprite_id[arg1] = -1; } void HuWinDispOff(s16 arg0) { @@ -1410,11 +1419,11 @@ void HuWinDispOff(s16 arg0) { s16 var_r30; for (var_r30 = 0; var_r30 < 30; var_r30++) { - if (temp_r31->unk06[var_r30] != -1) { - HuSprAttrSet(temp_r31->unk04, var_r30, 4); + if (temp_r31->sprite_id[var_r30] != -1) { + HuSprAttrSet(temp_r31->group, var_r30, 4); } } - temp_r31->unk4C |= 8; + temp_r31->attr |= 8; } void HuWinDispOn(s16 arg0) { @@ -1422,11 +1431,11 @@ void HuWinDispOn(s16 arg0) { s16 var_r30; for (var_r30 = 0; var_r30 < 30; var_r30++) { - if (temp_r31->unk06[var_r30] != -1) { - HuSprAttrReset(temp_r31->unk04, var_r30, 4); + if (temp_r31->sprite_id[var_r30] != -1) { + HuSprAttrReset(temp_r31->group, var_r30, 4); } } - temp_r31->unk4C = temp_r31->unk4C & ~8; + temp_r31->attr = temp_r31->attr & ~8; } void HuWinComKeyWait(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s16 arg4) { @@ -1464,11 +1473,11 @@ void HuWinComKeySet(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { } void _HuWinComKeySet(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s16 arg4) { - winComKeyBuf[comKeyIdx].unk04[0] = arg0; - winComKeyBuf[comKeyIdx].unk04[1] = arg1; - winComKeyBuf[comKeyIdx].unk04[2] = arg2; - winComKeyBuf[comKeyIdx].unk04[3] = arg3; - winComKeyBuf[comKeyIdx].unk00 = arg4; + winComKeyBuf[comKeyIdx].player[0] = arg0; + winComKeyBuf[comKeyIdx].player[1] = arg1; + winComKeyBuf[comKeyIdx].player[2] = arg2; + winComKeyBuf[comKeyIdx].player[3] = arg3; + winComKeyBuf[comKeyIdx].time = arg4; comKeyIdx++; comKeyIdx &= 0xFF; } @@ -1479,7 +1488,7 @@ void HuWinComKeyGet(s16 arg0, u32* arg1) { if (comKeyIdx == comKeyIdxNow) { for (var_r31 = 0; var_r31 < 4; var_r31++) { - if (!(temp_r30->unk02 & (1 << var_r31))) { + if (!(temp_r30->player_disable & (1 << var_r31))) { arg1[var_r31] = HuPadDStkRep[var_r31] | HuPadBtnDown[var_r31]; } else { arg1[var_r31] = 0; @@ -1487,17 +1496,17 @@ void HuWinComKeyGet(s16 arg0, u32* arg1) { } } else { for (var_r31 = 0; var_r31 < 4; var_r31++) { - arg1[var_r31] = winComKeyBuf[comKeyIdxNow].unk04[var_r31]; + arg1[var_r31] = winComKeyBuf[comKeyIdxNow].player[var_r31]; if (arg1[var_r31] == 0xFFFFFFFF) { - if (!(temp_r30->unk02 & (1 << var_r31))) { + if (!(temp_r30->player_disable & (1 << var_r31))) { arg1[var_r31] = HuPadDStkRep[var_r31] | HuPadBtnDown[var_r31]; } else { arg1[var_r31] = 0; } } } - winComKeyBuf[comKeyIdxNow].unk00--; - if (winComKeyBuf[comKeyIdxNow].unk00 <= 0) { + winComKeyBuf[comKeyIdxNow].time--; + if (winComKeyBuf[comKeyIdxNow].time <= 0) { comKeyIdxNow++; comKeyIdxNow &= 0xFF; } @@ -1638,7 +1647,7 @@ static void GetMesMaxSizeSub(u32 arg0) { break; case 0xE: var_r31++; - var_r29 = spcFontTbl[*var_r31 - 1].unk06 + 1; + var_r29 = spcFontTbl[*var_r31 - 1].w + 1; break; case 0x1F: var_r31++; @@ -1684,7 +1693,7 @@ static s32 GetMesMaxSizeSub2(SomeWindowStruct* arg0, u8* arg1) { case 0x20: break; case 0xA: - if (var_r27 != 0 && !(arg0->unk4C & 0x100)) { + if (var_r27 != 0 && !(arg0->attr & 0x100)) { var_r29 = 0; var_r26 = 1; } @@ -1711,7 +1720,7 @@ static s32 GetMesMaxSizeSub2(SomeWindowStruct* arg0, u8* arg1) { break; case 0xE: var_r31++; - var_r29 = spcFontTbl[*var_r31 - 1].unk06 + 1; + var_r29 = spcFontTbl[*var_r31 - 1].w + 1; break; case 0x1F: var_r31++; @@ -1747,19 +1756,19 @@ s32 HuWinKeyWaitNumGet(u32 arg0) { void HuWinPushKeySet(s16 arg0, s16 arg1) { SomeWindowStruct* temp_r31 = &winData[arg0]; - temp_r31->unk154 = arg1; + temp_r31->push_key = arg1; } void HuWinDisablePlayerSet(s16 arg0, u8 arg1) { SomeWindowStruct* temp_r31 = &winData[arg0]; - temp_r31->unk02 |= arg1; + temp_r31->player_disable |= arg1; } void HuWinDisablePlayerReset(s16 arg0, s32 arg1) { SomeWindowStruct* temp_r31 = &winData[arg0]; - temp_r31->unk02 &= ~arg1; + temp_r31->player_disable &= ~arg1; } void HuWinExCreate(f32 arg0, f32 arg1, s16 arg2, s16 arg3, s16 arg4) { @@ -1767,25 +1776,25 @@ void HuWinExCreate(f32 arg0, f32 arg1, s16 arg2, s16 arg3, s16 arg4) { } static s32 winPortraitTbl[] = { - 0x0086000F, - 0x00860010, - 0x00860011, - 0x00860012, - 0x00860013, - 0x00860014, - 0x00860015, - 0x00860016, - 0x00860017, - 0x00860018, - 0x00860019, - 0x0086001A, - 0x0086001B, - 0x00860009, - 0x0086000A, - 0x0086000B, - 0x0086000C, - 0x0086000D, - 0x0086000E + MAKE_DATA_NUM(DATADIR_WIN, 15), + MAKE_DATA_NUM(DATADIR_WIN, 16), + MAKE_DATA_NUM(DATADIR_WIN, 17), + MAKE_DATA_NUM(DATADIR_WIN, 18), + MAKE_DATA_NUM(DATADIR_WIN, 19), + MAKE_DATA_NUM(DATADIR_WIN, 20), + MAKE_DATA_NUM(DATADIR_WIN, 21), + MAKE_DATA_NUM(DATADIR_WIN, 22), + MAKE_DATA_NUM(DATADIR_WIN, 23), + MAKE_DATA_NUM(DATADIR_WIN, 24), + MAKE_DATA_NUM(DATADIR_WIN, 25), + MAKE_DATA_NUM(DATADIR_WIN, 26), + MAKE_DATA_NUM(DATADIR_WIN, 27), + MAKE_DATA_NUM(DATADIR_WIN, 9), + MAKE_DATA_NUM(DATADIR_WIN, 10), + MAKE_DATA_NUM(DATADIR_WIN, 11), + MAKE_DATA_NUM(DATADIR_WIN, 12), + MAKE_DATA_NUM(DATADIR_WIN, 13), + MAKE_DATA_NUM(DATADIR_WIN, 14) }; static inline void HuWinExCreateStyledInlineFunc(s16 arg0, s16 arg1, f32 arg2, f32 arg3) { @@ -1794,10 +1803,10 @@ static inline void HuWinExCreateStyledInlineFunc(s16 arg0, s16 arg1, f32 arg2, f SomeWindowStruct* var_3; void* var_4; - var_4 = HuAR_ARAMtoMRAMFileRead(winPortraitTbl[arg1], 0x10000000, 2); + var_4 = HuAR_ARAMtoMRAMFileRead(winPortraitTbl[arg1], MEMORY_DEFAULT_NUM, 2); var_2 = HuSprAnimRead(var_4); var_3 = &winData[arg0]; - var_1 = HuSprCreate(var_2, var_3->unk48 - 1, 0); + var_1 = HuSprCreate(var_2, var_3->prio - 1, 0); HuWinSprSet(arg0, var_1, arg2, arg3); } @@ -1811,7 +1820,7 @@ s16 HuWinExCreateStyled(f32 arg0, f32 arg1, s16 arg2, s16 arg3, s16 arg4, s16 ar temp_r28 = HuWinCreate(arg0, arg1, arg2, arg3, arg5); temp_r24 = &winData[temp_r28]; if (arg5 == 1) { - temp_r24->unk62 = 9; + temp_r24->mess_shadow_color = 9; } if (arg4 >= 0) { HuWinExCreateStyledInlineFunc(temp_r28, arg4, 48.0f, 48.0f); @@ -1826,31 +1835,31 @@ void HuWinExAnimIn(s16 arg0) { s16 temp_r22; _HuWinHomeClear(temp_r31); - if (temp_r31->unk06[2] == -1) { - HuSprScaleSet(temp_r31->unk04, 0, 1.0f, 0.0f); + if (temp_r31->sprite_id[2] == -1) { + HuSprScaleSet(temp_r31->group, 0, 1.0f, 0.0f); HuWinDispOn(arg0); for (var_r30 = 0; var_r30 <= 10; var_r30++) { - HuSprScaleSet(temp_r31->unk04, 0, 1.0f, 1.0 - 1.1 * cos(M_PI * (9.0f * var_r30) / 180.0)); + HuSprScaleSet(temp_r31->group, 0, 1.0f, 1.0 - 1.1 * cos(M_PI * (9.0f * var_r30) / 180.0)); HuPrcVSleep(); } - HuSprScaleSet(temp_r31->unk04, 0, 1.0f, 1.0f); + HuSprScaleSet(temp_r31->group, 0, 1.0f, 1.0f); } else { - HuSprScaleSet(temp_r31->unk04, 0, 1.0f, 0.0f); - HuSprScaleSet(temp_r31->unk04, 2, 1.0f, 0.0f); + HuSprScaleSet(temp_r31->group, 0, 1.0f, 0.0f); + HuSprScaleSet(temp_r31->group, 2, 1.0f, 0.0f); HuWinDispOn(arg0); for (var_r30 = 0; var_r30 <= 20; var_r30++) { if (var_r30 <= 10) { - HuSprScaleSet(temp_r31->unk04, 0, 1.0f, 1.1 * (1.0 - cos(M_PI * (9.0f * var_r30) / 180.0))); + HuSprScaleSet(temp_r31->group, 0, 1.0f, 1.1 * (1.0 - cos(M_PI * (9.0f * var_r30) / 180.0))); } else { - HuSprScaleSet(temp_r31->unk04, 0, 1.0f, 1.0f); + HuSprScaleSet(temp_r31->group, 0, 1.0f, 1.0f); } if (var_r30 > 10) { temp_r22 = var_r30 - 10; - HuSprScaleSet(temp_r31->unk04, 2, 1.0f, 1.0 - 1.1 * cos(M_PI * (9.0f * temp_r22) / 180.0)); + HuSprScaleSet(temp_r31->group, 2, 1.0f, 1.0 - 1.1 * cos(M_PI * (9.0f * temp_r22) / 180.0)); } HuPrcVSleep(); } - HuSprScaleSet(temp_r31->unk04, 2, 1.0f, 1.0f); + HuSprScaleSet(temp_r31->group, 2, 1.0f, 1.0f); } } @@ -1861,20 +1870,20 @@ void HuWinExAnimOut(s16 arg0) { s16 temp_r22; _HuWinHomeClear(temp_r31); - if (temp_r31->unk06[2] == -1) { + if (temp_r31->sprite_id[2] == -1) { for (var_r30 = 0; var_r30 <= 10; var_r30++) { - HuSprScaleSet(temp_r31->unk04, 0, 1.0f, cos(M_PI * (9.0f * var_r30) / 180.0)); + HuSprScaleSet(temp_r31->group, 0, 1.0f, cos(M_PI * (9.0f * var_r30) / 180.0)); HuPrcVSleep(); } HuWinDispOff(arg0); } else { for (var_r30 = 0; var_r30 <= 15; var_r30++) { if (var_r30 <= 10) { - HuSprScaleSet(temp_r31->unk04, 2, 1.0f, cos(M_PI * (9.0f * var_r30) / 180.0)); + HuSprScaleSet(temp_r31->group, 2, 1.0f, cos(M_PI * (9.0f * var_r30) / 180.0)); } if (var_r30 > 5) { temp_r22 = var_r30 - 5; - HuSprScaleSet(temp_r31->unk04, 0, 1.0f, cos(M_PI * (9.0f * temp_r22) / 180.0)); + HuSprScaleSet(temp_r31->group, 0, 1.0f, cos(M_PI * (9.0f * temp_r22) / 180.0)); } HuPrcVSleep(); } @@ -1891,14 +1900,14 @@ void HuWinExAnimPopIn(s16 arg0, s16 arg1) { s16 var_r30; for (var_r30 = 0; var_r30 <= 10; var_r30++) { - HuSprScaleSet(temp_r28->unk04, 2, 1.0f, cos(M_PI * (9.0f * var_r30) / 180.0)); + HuSprScaleSet(temp_r28->group, 2, 1.0f, cos(M_PI * (9.0f * var_r30) / 180.0)); HuPrcVSleep(); } HuWinSprKill(arg0, 2); HuWinExCreateStyledInlineFunc(arg0, arg1, 48.0f, 48.0f); for (var_r30 = 0; var_r30 <= 10; var_r30++) { - HuSprScaleSet(temp_r28->unk04, 2, 1.0f, sin(M_PI * (9.0f * var_r30) / 180.0)); + HuSprScaleSet(temp_r28->group, 2, 1.0f, sin(M_PI * (9.0f * var_r30) / 180.0)); HuPrcVSleep(); } - HuSprScaleSet(temp_r28->unk04, 2, 1.0f, 1.0f); + HuSprScaleSet(temp_r28->group, 2, 1.0f, 1.0f); } From f5343fb9e4a898f03bb1e0e907932fb58687c845 Mon Sep 17 00:00:00 2001 From: gamemasterplc Date: Fri, 22 Dec 2023 17:22:51 -0600 Subject: [PATCH 2/4] Label variables in all functions of window.c --- include/game/window.h | 8 +- src/game/window.c | 2070 +++++++++++++++++++++-------------------- 2 files changed, 1045 insertions(+), 1033 deletions(-) diff --git a/include/game/window.h b/include/game/window.h index d4009df6..9be6c154 100644 --- a/include/game/window.h +++ b/include/game/window.h @@ -66,12 +66,12 @@ typedef struct { /* 0x14C */ s16 scissor_y; /* 0x14E */ s16 scissor_w; /* 0x150 */ s16 scissor_h; - /* 0x152 */ s16 char_w; + /* 0x152 */ s16 tab_w; /* 0x154 */ s16 push_key; /* 0x156 */ s16 key_down; /* 0x158 */ s16 key_auto; /* 0x160 */ u8 ATTRIBUTE_ALIGN(32) mess_pal[10][3]; -} SomeWindowStruct; // Size 0x180 +} WindowData; // Size 0x180 void HuWindowInit(void); void HuWinInit(s32 arg0); @@ -80,8 +80,8 @@ void HuWinKill(s16 arg0); void HuWinAllKill(void); void HuWinHomeClear(s16 arg0); void HuWinKeyWaitEntry(s16 arg0); -u32 HuWinActivePadGet(SomeWindowStruct* arg0); -u32 HuWinActiveKeyGetX(SomeWindowStruct* arg0); +u32 HuWinActivePadGet(WindowData* arg0); +u32 HuWinActiveKeyGetX(WindowData* arg0); void HuWinPosSet(s16 arg0, f32 arg1, f32 arg2); void HuWinScaleSet(s16 arg0, f32 arg1, f32 arg2); void HuWinZRotSet(s16 arg0, f32 arg1); diff --git a/src/game/window.c b/src/game/window.c index c5e6335a..815ce8f5 100644 --- a/src/game/window.c +++ b/src/game/window.c @@ -31,14 +31,14 @@ static void MesDispFunc(SpriteData*); static u8 winBGMake(AnimData*, AnimData*); static void HuWinProc(void); static void HuWinDrawMes(s16 arg0); -static s32 HuWinCR(SomeWindowStruct* arg0); -static void _HuWinHomeClear(SomeWindowStruct* arg0); +static s32 HuWinCR(WindowData* arg0); +static void _HuWinHomeClear(WindowData* arg0); static void HuWinKeyWait(s16 arg0); -static s16 HuWinSpcFontEntry(SomeWindowStruct* arg0, s16 arg1, s16 arg2, s16 arg3); -static void HuWinSpcFontClear(SomeWindowStruct* arg0); -static void HuWinChoice(SomeWindowStruct* arg0); +static s16 HuWinSpcFontEntry(WindowData* arg0, s16 arg1, s16 arg2, s16 arg3); +static void HuWinSpcFontClear(WindowData* arg0); +static void HuWinChoice(WindowData* arg0); static void GetMesMaxSizeSub(u32 arg0); -static s32 GetMesMaxSizeSub2(SomeWindowStruct* arg0, u8* arg1); +static s32 GetMesMaxSizeSub2(WindowData* arg0, u8* arg1); void* HuAR_DVDtoARAM(s32); void* HuAR_ARAMtoMRAMFileRead(s32, s32, s32); @@ -53,7 +53,7 @@ void* MessData_MesPtrGet(void*, u32); extern u16 HuPadBtn[4]; extern u8 HuPadDStkRep[4]; -SomeWindowStruct ATTRIBUTE_ALIGN(32) winData[32]; +WindowData ATTRIBUTE_ALIGN(32) winData[32]; u32 winKey[4]; keyBufData winComKeyBuf[256]; @@ -208,49 +208,49 @@ void HuWindowInit(void) { winPrio = 1000; } -void HuWinInit(s32 arg0) { - s16 var_r30; - void* var_r31; - s8 temp_r28; +void HuWinInit(s32 mess_data_no) { + s16 i; + void* anim_data; + s8 language; - if (winProc == 0) { + if (!winProc) { HuAR_ARAMtoMRAM(winAMemP); winProc = HuPrcCreate(HuWinProc, 0x64, 0x1000, 0); HuPrcSetStat(winProc, 0xC); - temp_r28 = GWGameStat.language; - LanguageNo = temp_r28; - messDataNo = arg0; + language = GWGameStat.language; + LanguageNo = language; + messDataNo = mess_data_no; fontWidthP = (LanguageNo == 0) ? charWJTbl : charWETbl; - HuWinMesRead(arg0); - for (var_r30 = 0; var_r30 < 32; var_r30++) { - winData[var_r30].group = -1; + HuWinMesRead(mess_data_no); + for (i = 0; i < 32; i++) { + winData[i].group = -1; } if (!fontAnim) { if (LanguageNo == 0) { - var_r31 = HuDataReadNum(MAKE_DATA_NUM(DATADIR_WIN, 0), MEMORY_DEFAULT_NUM); + anim_data = HuDataReadNum(MAKE_DATA_NUM(DATADIR_WIN, 0), MEMORY_DEFAULT_NUM); } else { - var_r31 = HuDataReadNum(MAKE_DATA_NUM(DATADIR_WIN, 1), MEMORY_DEFAULT_NUM); + anim_data = HuDataReadNum(MAKE_DATA_NUM(DATADIR_WIN, 1), MEMORY_DEFAULT_NUM); } - fontAnim = HuSprAnimRead(var_r31); + fontAnim = HuSprAnimRead(anim_data); } if (!iconAnim) { - var_r31 = HuDataReadNum(MAKE_DATA_NUM(DATADIR_WIN, 3), MEMORY_DEFAULT_NUM); - iconAnim = HuSprAnimRead(var_r31); + anim_data = HuDataReadNum(MAKE_DATA_NUM(DATADIR_WIN, 3), MEMORY_DEFAULT_NUM); + iconAnim = HuSprAnimRead(anim_data); HuSprAnimLock(iconAnim); } if (!cursorAnim) { - var_r31 = HuDataReadNum(MAKE_DATA_NUM(DATADIR_WIN, 2), MEMORY_DEFAULT_NUM); - cursorAnim = HuSprAnimRead(var_r31); + anim_data = HuDataReadNum(MAKE_DATA_NUM(DATADIR_WIN, 2), MEMORY_DEFAULT_NUM); + cursorAnim = HuSprAnimRead(anim_data); HuSprAnimLock(cursorAnim); } if (!cardAnimA) { - var_r31 = HuDataReadNum(MAKE_DATA_NUM(DATADIR_WIN, 4), MEMORY_DEFAULT_NUM); - cardAnimA = HuSprAnimRead(var_r31); + anim_data = HuDataReadNum(MAKE_DATA_NUM(DATADIR_WIN, 4), MEMORY_DEFAULT_NUM); + cardAnimA = HuSprAnimRead(anim_data); HuSprAnimLock(cardAnimA); } if (!cardAnimB) { - var_r31 = HuDataReadNum(MAKE_DATA_NUM(DATADIR_WIN, 5), MEMORY_DEFAULT_NUM); - cardAnimB = HuSprAnimRead(var_r31); + anim_data = HuDataReadNum(MAKE_DATA_NUM(DATADIR_WIN, 5), MEMORY_DEFAULT_NUM); + cardAnimB = HuSprAnimRead(anim_data); HuSprAnimLock(cardAnimB); } HuDataDirClose(MAKE_DIR_NUM(DATADIR_WIN)); @@ -260,130 +260,130 @@ void HuWinInit(s32 arg0) { } s16 HuWinCreate(f32 x, f32 y, s16 w, s16 h, s16 frame) { - AnimData* temp_r3_3; - SomeWindowStruct* temp_r31; - SpriteData* temp_r22; - s16 temp_r3; - s16 temp_r3_2; - s16 var_r29; - s16 var_r30; - void* temp_r21; + AnimData *bg_anim; + WindowData *window; + SpriteData *sprite_ptr; + s16 group; + s16 sprite; + s16 window_id; + s16 i; + void *frame_data; - for (var_r29 = 0; var_r29 < 32; var_r29++) { - if (winData[var_r29].group == -1) { + for (window_id = 0; window_id < 32; window_id++) { + if (winData[window_id].group == -1) { break; } } - if (var_r29 == 0x20) { + if (window_id == 32) { return -1; } - temp_r31 = &winData[var_r29]; - temp_r31->group = temp_r3 = HuSprGrpCreate(0x1E); + window = &winData[window_id]; + window->group = group = HuSprGrpCreate(30); if (frame < 0 || frame >= 4) { frame = 0; } - w = (w + 0xF) & 0xFFF0; - h = (h + 0xF) & 0xFFF0; + w = (w + 15) & 0xFFF0; + h = (h + 15) & 0xFFF0; if (x == -10000.0f) { - temp_r31->pos_x = (576.0f - w) / 2; + window->pos_x = (576.0f - w) / 2; } else { - temp_r31->pos_x = x; + window->pos_x = x; } if (y == -10000.0f) { - temp_r31->pos_y = (480.0f - h) / 2; + window->pos_y = (480.0f - h) / 2; } else { - temp_r31->pos_y = y; + window->pos_y = y; } - HuSprGrpCenterSet(temp_r3, w / 2, h / 2); - HuSprGrpPosSet(temp_r3, temp_r31->pos_x, temp_r31->pos_y); - temp_r21 = HuAR_ARAMtoMRAMFileRead(frameFileTbl[frame], MEMORY_DEFAULT_NUM, 2); - temp_r31->frame = HuSprAnimRead(temp_r21); - temp_r3_2 = temp_r31->sprite_id[0] = HuSprCreate(temp_r31->frame, winPrio, 0); - HuSprGrpMemberSet(temp_r3, 0, temp_r3_2); - HuSprTPLvlSet(temp_r3, 0, 0.9f); - temp_r3_3 = HuSprAnimMake(w / 16, h / 16, 6); - HuSprBGSet(temp_r3, 0, temp_r3_3, 0); - temp_r31->color_key = winBGMake(temp_r3_3, temp_r31->frame); - temp_r3_2 = temp_r31->sprite_id[1] = HuSprFuncCreate(MesDispFunc, winPrio); - temp_r22 = &HuSprData[temp_r3_2]; - temp_r22->work[0] = var_r29; - HuSprGrpMemberSet(temp_r3, 1, temp_r3_2); - temp_r31->num_chars = 0; - temp_r31->max_chars = (w / 8) * (h / 24) * 4; - temp_r31->char_data = HuMemDirectMalloc(HEAP_SYSTEM, temp_r31->max_chars * sizeof(WinChar)); - temp_r31->attr = 0; - temp_r31->stat = 0; - temp_r31->unk8C = 0; - temp_r31->mess_time = 0; - temp_r31->mess_x = temp_r31->mess_y = 0; - temp_r31->mess_rect_x = 8; - temp_r31->mess_rect_y = 8; - temp_r31->mess_rect_w = w - 8; - temp_r31->mess_rect_h = h - 8; - temp_r31->speed = 1; - temp_r31->mess_color = 7; - temp_r31->mess_shadow_color = 0; - temp_r31->active_pad = 0xF; - temp_r31->player_disable = 0; - temp_r31->mess_stackptr = 0; - temp_r31->mess = 0; - temp_r31->num_choices = 0; - temp_r31->prio = winPrio; - temp_r31->spacing_x = 1; - temp_r31->spacing_y = 2; - temp_r31->w = w; - temp_r31->h = h; - temp_r31->scissor_x = temp_r31->scissor_y = 0; - temp_r31->scissor_w = 0x280; - temp_r31->scissor_h = 0x1E0; - temp_r31->char_w = 0x18; - temp_r31->push_key = 0x300; - temp_r31->key_auto = 0; + HuSprGrpCenterSet(group, w / 2, h / 2); + HuSprGrpPosSet(group, window->pos_x, window->pos_y); + frame_data = HuAR_ARAMtoMRAMFileRead(frameFileTbl[frame], MEMORY_DEFAULT_NUM, 2); + window->frame = HuSprAnimRead(frame_data); + sprite = window->sprite_id[0] = HuSprCreate(window->frame, winPrio, 0); + HuSprGrpMemberSet(group, 0, sprite); + HuSprTPLvlSet(group, 0, 0.9f); + bg_anim = HuSprAnimMake(w / 16, h / 16, 6); + HuSprBGSet(group, 0, bg_anim, 0); + window->color_key = winBGMake(bg_anim, window->frame); + sprite = window->sprite_id[1] = HuSprFuncCreate(MesDispFunc, winPrio); + sprite_ptr = &HuSprData[sprite]; + sprite_ptr->work[0] = window_id; + HuSprGrpMemberSet(group, 1, sprite); + window->num_chars = 0; + window->max_chars = (w / 8) * (h / 24) * 4; + window->char_data = HuMemDirectMalloc(HEAP_SYSTEM, window->max_chars * sizeof(WinChar)); + window->attr = 0; + window->stat = 0; + window->unk8C = 0; + window->mess_time = 0; + window->mess_x = window->mess_y = 0; + window->mess_rect_x = 8; + window->mess_rect_y = 8; + window->mess_rect_w = w - 8; + window->mess_rect_h = h - 8; + window->speed = 1; + window->mess_color = 7; + window->mess_shadow_color = 0; + window->active_pad = 0xF; + window->player_disable = 0; + window->mess_stackptr = 0; + window->mess = 0; + window->num_choices = 0; + window->prio = winPrio; + window->spacing_x = 1; + window->spacing_y = 2; + window->w = w; + window->h = h; + window->scissor_x = window->scissor_y = 0; + window->scissor_w = 0x280; + window->scissor_h = 0x1E0; + window->tab_w = 24; + window->push_key = 0x300; + window->key_auto = 0; if (frame == 0 || frame == 2) { - memcpy(&temp_r31->mess_pal, &charColPal[30], 30); + memcpy(&window->mess_pal, &charColPal[30], 30); } else { - memcpy(&temp_r31->mess_pal, charColPal, 30); - temp_r31->mess_shadow_color = 9; + memcpy(&window->mess_pal, charColPal, 30); + window->mess_shadow_color = 9; } - for (var_r30 = 0; var_r30 < 8; var_r30++) { - temp_r31->insert_mess[var_r30] = 0; + for (i = 0; i < 8; i++) { + window->insert_mess[i] = 0; } - for (var_r30 = 2; var_r30 < 30; var_r30++) { - temp_r31->sprite_id[var_r30] = -1; + for (i = 2; i < 30; i++) { + window->sprite_id[i] = -1; } winPrio -= 3; if (winPrio < 500) { winPrio = 1000; } - for (var_r30 = 0; var_r30 < 16; var_r30++) { - temp_r31->choice_disable[var_r30] = 0; - temp_r31->choice_data[var_r30].stat = 0; + for (i = 0; i < 16; i++) { + window->choice_disable[i] = 0; + window->choice_data[i].stat = 0; } - return var_r29; + return window_id; } -void HuWinKill(s16 arg0) { - SomeWindowStruct* temp_r31 = &winData[arg0]; - s16 var_r30; +void HuWinKill(s16 window_id) { + WindowData *window = &winData[window_id]; + s16 i; - if (temp_r31->group != -1) { - HuMemDirectFree(temp_r31->char_data); - for (var_r30 = 2; var_r30 < 30; var_r30++) { - if (temp_r31->sprite_id[var_r30] != -1) { - HuSprGrpMemberKill(temp_r31->group, var_r30); + if (window->group != -1) { + HuMemDirectFree(window->char_data); + for (i = 2; i < 30; i++) { + if (window->sprite_id[i] != -1) { + HuSprGrpMemberKill(window->group, i); } } - HuSprGrpKill(temp_r31->group); - temp_r31->group = -1; + HuSprGrpKill(window->group); + window->group = -1; } } void HuWinAllKill(void) { - s16 var_r30; + s16 i; - for (var_r30 = 0; var_r30 < 32; var_r30++) { - if (winData[var_r30].group != -1) { - HuWinKill(var_r30); + for (i = 0; i < 32; i++) { + if (winData[i].group != -1) { + HuWinKill(i); } } if (fontAnim != 0) { @@ -414,32 +414,32 @@ void HuWinAllKill(void) { HuMemDirectFree(messDataPtr); messDataPtr = 0; } - HuDataDirClose(0x860000); + HuDataDirClose(MAKE_DIR_NUM(DATADIR_WIN)); } -static void MesDispFunc(SpriteData* arg0) { - SomeWindowStruct* temp_r31 = &winData[arg0->work[0]]; - SpriteGroupData* spC; - f32 temp_f26; - f32 temp_f25; - f32 temp_f29; - f32 temp_f28; - f32 temp_f27; - f32 temp_f31; - f32 temp_f30; - f32 var_f23; - s16 var_r29; - u16 temp_r27; - s16 temp_r28; - Mtx sp80; - Mtx sp50; - Mtx44 sp10; +static void MesDispFunc(SpriteData *sprite) { + WindowData *window = &winData[sprite->work[0]]; + SpriteGroupData *group; + f32 uv_maxx; + f32 uv_maxy; + f32 uv_minx; + f32 uv_miny; + f32 char_w; + f32 char_x; + f32 char_y; + f32 char_uv_h; + s16 i; + u16 alpha; + s16 color; + Mtx scale; + Mtx modelview; + Mtx44 proj; - if (temp_r31->num_chars != 0) { - spC = &HuSprGrpData[temp_r31->group]; + if (window->num_chars != 0) { + group = &HuSprGrpData[window->group]; GXInvalidateTexAll(); - C_MTXOrtho(sp10, 0.0f, 480.0f, 0.0f, 576.0f, 0.0f, 10.0f); - GXSetProjection(sp10, GX_ORTHOGRAPHIC); + C_MTXOrtho(proj, 0.0f, 480.0f, 0.0f, 576.0f, 0.0f, 10.0f); + GXSetProjection(proj, GX_ORTHOGRAPHIC); GXClearVtxDesc(); GXSetVtxDesc(GX_VA_POS, GX_DIRECT); GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT); @@ -449,7 +449,7 @@ static void MesDispFunc(SpriteData* arg0) { GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_TEX_S, GX_RGBA8, 0); GXSetCullMode(GX_CULL_NONE); GXSetNumTexGens(1); - GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 0x3C, 0, 0x7D); + GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); GXSetNumTevStages(1); GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_RASC, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO); GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV); @@ -460,138 +460,138 @@ static void MesDispFunc(SpriteData* arg0) { GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_NOOP); GXSetAlphaCompare(GX_GEQUAL, 1, GX_AOP_AND, GX_GEQUAL, 1); GXSetZCompLoc(0); - PSMTXRotRad(sp50, 0x7A, 0.017453292f * arg0->z_rot); - PSMTXScale(sp80, arg0->scale_x, arg0->scale_y, 1.0f); - PSMTXConcat(sp50, sp80, sp50); - mtxTransCat(sp50, arg0->x, arg0->y, 0.0f); - PSMTXConcat(*arg0->group_mtx, sp50, sp50); - GXLoadPosMtxImm(sp50, 0); + MTXRotRad(modelview, 'z', MTXDegToRad(sprite->z_rot)); + MTXScale(scale, sprite->scale_x, sprite->scale_y, 1.0f); + MTXConcat(modelview, scale, modelview); + mtxTransCat(modelview, sprite->x, sprite->y, 0.0f); + MTXConcat(*sprite->group_mtx, modelview, modelview); + GXLoadPosMtxImm(modelview, 0); GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); HuSprTexLoad(fontAnim, 0, 0, GX_CLAMP, GX_CLAMP, GX_LINEAR); - GXBegin(GX_QUADS, GX_VTXFMT0, temp_r31->num_chars * 4); - var_f23 = (LanguageNo == 0) ? 0.05882353f : 0.07692308f; - for (var_r29 = 0; var_r29 < temp_r31->num_chars; var_r29++) { - temp_f27 = fontWidthP[temp_r31->char_data[var_r29].character + 0x30]; - temp_f29 = 0.0625f * (temp_r31->char_data[var_r29].character % 16); - temp_f28 = var_f23 * (temp_r31->char_data[var_r29].character / 16); - temp_f26 = temp_f29 + (temp_f27 / 320.0); - temp_f25 = temp_f28 + var_f23; - temp_f31 = temp_r31->char_data[var_r29].x; - temp_f30 = temp_r31->char_data[var_r29].y; - temp_r28 = temp_r31->char_data[var_r29].color; - if (temp_r31->speed != 0) { - temp_r27 = temp_r31->char_data[var_r29].fade * 8; + GXBegin(GX_QUADS, GX_VTXFMT0, window->num_chars * 4); + char_uv_h = (LanguageNo == 0) ? (24.0f/408.0f) : (24.0f/312.0f); + for (i = 0; i < window->num_chars; i++) { + char_w = fontWidthP[window->char_data[i].character + 48]; + uv_minx = (20.0f/320.0f) * (window->char_data[i].character % 16); + uv_miny = char_uv_h * (window->char_data[i].character / 16); + uv_maxx = uv_minx + (char_w / 320.0); + uv_maxy = uv_miny + char_uv_h; + char_x = window->char_data[i].x; + char_y = window->char_data[i].y; + color = window->char_data[i].color; + if (window->speed != 0) { + alpha = window->char_data[i].fade * 8; } else { - temp_r27 = 0xFF; + alpha = 255; } - temp_r27 = 0xFF; - if (temp_r31->char_data[var_r29].fade < 0x1F) { - temp_r31->char_data[var_r29].fade++; + alpha = 255; + if (window->char_data[i].fade < 31) { + window->char_data[i].fade++; } - GXPosition3f32(temp_f31 + 1.0f, temp_f30, 0.0f); - GXColor4u8(temp_r31->mess_pal[temp_r28][0], temp_r31->mess_pal[temp_r28][1], temp_r31->mess_pal[temp_r28][2], temp_r27); - GXTexCoord2f32(temp_f29, temp_f28); - GXPosition3f32(temp_f31 + temp_f27, temp_f30, 0.0f); - GXColor4u8(temp_r31->mess_pal[temp_r28][0], temp_r31->mess_pal[temp_r28][1], temp_r31->mess_pal[temp_r28][2], temp_r27); - GXTexCoord2f32(temp_f26, temp_f28); - GXPosition3f32(temp_f31 + temp_f27, temp_f30 + 24.0f, 0.0f); - GXColor4u8(temp_r31->mess_pal[temp_r28][0], temp_r31->mess_pal[temp_r28][1], temp_r31->mess_pal[temp_r28][2], temp_r27); - GXTexCoord2f32(temp_f26, temp_f25); - GXPosition3f32(temp_f31 + 1.0f, temp_f30 + 24.0f, 0.0f); - GXColor4u8(temp_r31->mess_pal[temp_r28][0], temp_r31->mess_pal[temp_r28][1], temp_r31->mess_pal[temp_r28][2], temp_r27); - GXTexCoord2f32(temp_f29, temp_f25); + GXPosition3f32(char_x + 1.0f, char_y, 0.0f); + GXColor4u8(window->mess_pal[color][0], window->mess_pal[color][1], window->mess_pal[color][2], alpha); + GXTexCoord2f32(uv_minx, uv_miny); + GXPosition3f32(char_x + char_w, char_y, 0.0f); + GXColor4u8(window->mess_pal[color][0], window->mess_pal[color][1], window->mess_pal[color][2], alpha); + GXTexCoord2f32(uv_maxx, uv_miny); + GXPosition3f32(char_x + char_w, char_y + 24.0f, 0.0f); + GXColor4u8(window->mess_pal[color][0], window->mess_pal[color][1], window->mess_pal[color][2], alpha); + GXTexCoord2f32(uv_maxx, uv_maxy); + GXPosition3f32(char_x + 1.0f, char_y + 24.0f, 0.0f); + GXColor4u8(window->mess_pal[color][0], window->mess_pal[color][1], window->mess_pal[color][2], alpha); + GXTexCoord2f32(uv_minx, uv_maxy); } GXEnd(); mesCharCnt++; } } -static u8 winBGMake(AnimData* arg0, AnimData* arg1) { - AnimBmpData* temp_r25; - s16 temp_r22; - s16 temp_r23; - s16 temp_r27; - s16 temp_r28; - s16 var_r30; - s16 var_r31; - u8* temp_r3; - u16* var_r24; +static u8 winBGMake(AnimData *bg, AnimData *frame) { + AnimBmpData *bmp; + s16 block_h; + s16 h; + s16 block_w; + s16 w; + s16 i; + s16 j; + u8 *bmp_data; + u16 *palette; - temp_r28 = arg0->bmp->sizeX; - temp_r23 = arg0->bmp->sizeY; - temp_r27 = (temp_r28 + 7) & 0xF8; - temp_r22 = (temp_r23 + 3) & 0xFC; - temp_r3 = arg0->bmp->data = HuMemDirectMallocNum(HEAP_SYSTEM, temp_r27 * temp_r22, MEMORY_DEFAULT_NUM); - for (var_r30 = 0; var_r30 < temp_r23; var_r30++) { - if (var_r30 == 0) { - for (var_r31 = 0; var_r31 < temp_r28; var_r31++) { - if (var_r31 == 0) { - temp_r3[(var_r31 & 7) + ((var_r31 >> 3) << 5) + (var_r30 >> 2) * (temp_r27 * 4) + (var_r30 & 3) * 8] = 0; - } else if (var_r31 == temp_r28 - 1) { - temp_r3[(var_r31 & 7) + ((var_r31 >> 3) << 5) + (var_r30 >> 2) * (temp_r27 * 4) + (var_r30 & 3) * 8] = 0x10; + w = bg->bmp->sizeX; + h = bg->bmp->sizeY; + block_w = (w + 7) & 0xF8; + block_h = (h + 3) & 0xFC; + bmp_data = bg->bmp->data = HuMemDirectMallocNum(HEAP_SYSTEM, block_w * block_h, MEMORY_DEFAULT_NUM); + for (i = 0; i < h; i++) { + if (i == 0) { + for (j = 0; j < w; j++) { + if (j == 0) { + bmp_data[(j & 7) + ((j >> 3) << 5) + (i >> 2) * (block_w * 4) + (i & 3) * 8] = 0; + } else if (j == w-1) { + bmp_data[(j & 7) + ((j >> 3) << 5) + (i >> 2) * (block_w * 4) + (i & 3) * 8] = 0x10; } else { - temp_r3[(var_r31 & 7) + ((var_r31 >> 3) << 5) + (var_r30 >> 2) * (temp_r27 * 4) + (var_r30 & 3) * 8] = 0x70; + bmp_data[(j & 7) + ((j >> 3) << 5) + (i >> 2) * (block_w * 4) + (i & 3) * 8] = 0x70; } } - } else if (var_r30 == temp_r23 - 1) { - for (var_r31 = 0; var_r31 < temp_r28; var_r31++) { - if (var_r31 == 0) { - temp_r3[(var_r31 & 7) + ((var_r31 >> 3) << 5) + (var_r30 >> 2) * (temp_r27 * 4) + (var_r30 & 3) * 8] = 0x20; - } else if (var_r31 == temp_r28 - 1) { - temp_r3[(var_r31 & 7) + ((var_r31 >> 3) << 5) + (var_r30 >> 2) * (temp_r27 * 4) + (var_r30 & 3) * 8] = 0x30; + } else if (i == h-1) { + for (j = 0; j < w; j++) { + if (j == 0) { + bmp_data[(j & 7) + ((j >> 3) << 5) + (i >> 2) * (block_w * 4) + (i & 3) * 8] = 0x20; + } else if (j == w - 1) { + bmp_data[(j & 7) + ((j >> 3) << 5) + (i >> 2) * (block_w * 4) + (i & 3) * 8] = 0x30; } else { - temp_r3[(var_r31 & 7) + ((var_r31 >> 3) << 5) + (var_r30 >> 2) * (temp_r27 * 4) + (var_r30 & 3) * 8] = 0x60; + bmp_data[(j & 7) + ((j >> 3) << 5) + (i >> 2) * (block_w * 4) + (i & 3) * 8] = 0x60; } } } else { - for (var_r31 = 0; var_r31 < temp_r28; var_r31++) { - if (var_r31 == 0) { - temp_r3[(var_r31 & 7) + ((var_r31 >> 3) << 5) + (var_r30 >> 2) * (temp_r27 * 4) + (var_r30 & 3) * 8] = 0x40; - } else if (var_r31 == temp_r28 - 1) { - temp_r3[(var_r31 & 7) + ((var_r31 >> 3) << 5) + (var_r30 >> 2) * (temp_r27 * 4) + (var_r30 & 3) * 8] = 0x50; + for (j = 0; j < w; j++) { + if (j == 0) { + bmp_data[(j & 7) + ((j >> 3) << 5) + (i >> 2) * (block_w * 4) + (i & 3) * 8] = 0x40; + } else if (j == w-1) { + bmp_data[(j & 7) + ((j >> 3) << 5) + (i >> 2) * (block_w * 4) + (i & 3) * 8] = 0x50; } else { - temp_r3[(var_r31 & 7) + ((var_r31 >> 3) << 5) + (var_r30 >> 2) * (temp_r27 * 4) + (var_r30 & 3) * 8] = 0x80; + bmp_data[(j & 7) + ((j >> 3) << 5) + (i >> 2) * (block_w * 4) + (i & 3) * 8] = 0x80; } } } } - DCStoreRangeNoSync(arg0->bmp->data, temp_r27 * temp_r22); - temp_r25 = arg1->bmp; - var_r24 = temp_r25->palData; - for (temp_r28 = 0; temp_r28 < temp_r25->palNum; temp_r28++, var_r24++) { - if (*var_r24 == 0xFC00) { - *var_r24 = 0x6114; + DCStoreRangeNoSync(bg->bmp->data, block_w * block_h); + bmp = frame->bmp; + palette = bmp->palData; + for (w = 0; w < bmp->palNum; w++, palette++) { + if (*palette == 0xFC00) { + *palette = 0x6114; break; } } - DCStoreRangeNoSync(temp_r25->palData, 0x200); - return temp_r28; + DCStoreRangeNoSync(bmp->palData, 0x200); + return w; } static void HuWinProc(void) { - SomeWindowStruct* var_r31; - s16 var_r30; + WindowData *window; + s16 i; while (1) { HuPrcVSleep(); - var_r31 = winData; - for (var_r30 = 0; var_r30 < 32; var_r30++, var_r31++) { - if (var_r31->group != -1 && !(var_r31->attr & 8)) { - switch (var_r31->stat) { + window = winData; + for (i = 0; i < 32; i++, window++) { + if (window->group != -1 && !(window->attr & 8)) { + switch (window->stat) { case 0: break; case 1: - HuWinDrawMes(var_r30); + HuWinDrawMes(i); break; case 2: - HuWinComKeyGet(var_r30, winKey); - HuWinKeyWait(var_r30); + HuWinComKeyGet(i, winKey); + HuWinKeyWait(i); break; case 3: - if (!(var_r31->attr & 0x40) || HuWinActiveKeyGetX(var_r31) == 0) { - var_r31->attr &= ~0x40; - HuWinComKeyGet(var_r30, winKey); - HuWinChoice(var_r31); + if (!(window->attr & 0x40) || HuWinActiveKeyGetX(window) == 0) { + window->attr &= ~0x40; + HuWinComKeyGet(i, winKey); + HuWinChoice(window); } break; } @@ -600,422 +600,431 @@ static void HuWinProc(void) { } } -static inline void charEntry(s16 arg0, s16 arg1, s16 arg2, s16 arg3, s16 arg4) { - SomeWindowStruct* temp_r28 = &winData[arg0]; - WinChar *temp_r20 = temp_r28->char_data; +static inline void charEntry(s16 window, s16 x, s16 y, s16 char_idx, s16 color) { + WindowData *window_ptr = &winData[window]; + WinChar *win_char = window_ptr->char_data; - temp_r20 = &temp_r28->char_data[temp_r28->num_chars]; - temp_r20->x = arg1 - temp_r28->w / 2; - temp_r20->y = arg2 - temp_r28->h / 2; - temp_r20->character = arg3 - 0x30; - temp_r20->color = arg4; - temp_r20->fade = 0; - temp_r28->num_chars++; - if (temp_r28->num_chars >= temp_r28->max_chars) { - temp_r28->num_chars = temp_r28->max_chars - 1; + win_char = &window_ptr->char_data[window_ptr->num_chars]; + win_char->x = x - window_ptr->w / 2; + win_char->y = y - window_ptr->h / 2; + win_char->character = char_idx-48; + win_char->color = color; + win_char->fade = 0; + window_ptr->num_chars++; + if (window_ptr->num_chars >= window_ptr->max_chars) { + window_ptr->num_chars = window_ptr->max_chars-1; } } -static void HuWinDrawMes(s16 arg0) { - SomeWindowStruct* temp_r31 = &winData[arg0]; - SpriteGroupData* sp44 = &HuSprGrpData[temp_r31->group]; - s16 var_r30; - s16 sp34; - s16 sp32; - s16 sp30; - s16 sp2E; - s16 sp2C; - s16 sp2A; - s16 sp28; - s16 sp26; +static void HuWinDrawMes(s16 window) { + WindowData *window_ptr = &winData[window]; + SpriteGroupData *group = &HuSprGrpData[window_ptr->group]; + s16 c; + s16 i; + s16 char_w; + s16 tab_w; + s16 insert_mess; + s16 mess_end; + s16 shadow_color; + s16 color; + s16 mess_w; - temp_r31->mess_time += 3; - while (temp_r31->mess_time >= temp_r31->speed || (temp_r31->attr & 0x2000)) { - temp_r31->mess_time -= temp_r31->speed; - if (temp_r31->mess_time < 0) { - temp_r31->mess_time = 0; + window_ptr->mess_time += 3; + while (window_ptr->mess_time >= window_ptr->speed || (window_ptr->attr & 0x2000)) { + window_ptr->mess_time -= window_ptr->speed; + if(window_ptr->mess_time < 0) { + window_ptr->mess_time = 0; } - sp32 = temp_r31->spacing_x + fontWidthP[temp_r31->mess[0]]; - sp2C = 0; - if (temp_r31->mess[0] != 0 && (temp_r31->attr & 4)) { - temp_r31->attr &= ~4; - _HuWinHomeClear(temp_r31); + char_w = window_ptr->spacing_x + fontWidthP[window_ptr->mess[0]]; + mess_end = 0; + if (window_ptr->mess[0] != 0 && (window_ptr->attr & 4)) { + window_ptr->attr &= ~4; + _HuWinHomeClear(window_ptr); } - while (temp_r31->mess[0] < 0x30 || temp_r31->mess[0] == 0xFF) { - switch (temp_r31->mess[0]) { - case 0x0: - if (temp_r31->mess_stackptr == 0) { - for (sp34 = 0; sp34 < 16; sp34++) { - temp_r31->choice_disable[sp34] = 0; + while (window_ptr->mess[0] < 48 || window_ptr->mess[0] == 255) { + switch (window_ptr->mess[0]) { + case 0: + if (window_ptr->mess_stackptr == 0) { + for (i=0; i<16; i++) { + window_ptr->choice_disable[i] = 0; } - temp_r31->stat = 0; - temp_r31->attr &= ~0x80; + window_ptr->stat = 0; + window_ptr->attr &= ~0x80; return; } - temp_r31->mess_stackptr--; - temp_r31->mess = temp_r31->mess_stack[temp_r31->mess_stackptr]; - temp_r31->mess_time = 0; + window_ptr->mess_stackptr--; + window_ptr->mess = window_ptr->mess_stack[window_ptr->mess_stackptr]; + window_ptr->mess_time = 0; break; - case 0x1F: - temp_r31->mess++; - sp2E = temp_r31->mess[0] - 1; - if (temp_r31->insert_mess[sp2E] != 0) { - temp_r31->mess_stack[temp_r31->mess_stackptr] = temp_r31->mess; - temp_r31->mess = temp_r31->insert_mess[sp2E]; - temp_r31->mess_stackptr++; - if (temp_r31->mess[0] != 0xB) { - temp_r31->mess--; + + case 31: + window_ptr->mess++; + insert_mess = window_ptr->mess[0] - 1; + if (window_ptr->insert_mess[insert_mess] != 0) { + window_ptr->mess_stack[window_ptr->mess_stackptr] = window_ptr->mess; + window_ptr->mess = window_ptr->insert_mess[insert_mess]; + window_ptr->mess_stackptr++; + if (window_ptr->mess[0] != 0xB) { + window_ptr->mess--; } } break; - case 0xB: - temp_r31->attr &= ~0x2200; - _HuWinHomeClear(temp_r31); - if (temp_r31->attr & 0x800) { - sp26 = GetMesMaxSizeSub2(temp_r31, temp_r31->mess + 1); - temp_r31->mess_x = (temp_r31->mess_rect_w - sp26) / 2; - } else if (temp_r31->attr & 0x1000) { - sp26 = GetMesMaxSizeSub2(temp_r31, temp_r31->mess + 1); - temp_r31->mess_x = temp_r31->mess_rect_w - sp26; + + case 11: + window_ptr->attr &= ~0x2200; + _HuWinHomeClear(window_ptr); + if (window_ptr->attr & 0x800) { + mess_w = GetMesMaxSizeSub2(window_ptr, window_ptr->mess + 1); + window_ptr->mess_x = (window_ptr->mess_rect_w - mess_w) / 2; + } else if (window_ptr->attr & 0x1000) { + mess_w = GetMesMaxSizeSub2(window_ptr, window_ptr->mess + 1); + window_ptr->mess_x = window_ptr->mess_rect_w - mess_w; } break; - case 0x1E: - temp_r31->mess++; - if (!(temp_r31->attr & 0x80)) { - temp_r31->mess_color = temp_r31->mess[0] - 1; + + case 30: + window_ptr->mess++; + if (!(window_ptr->attr & 0x80)) { + window_ptr->mess_color = window_ptr->mess[0] - 1; } break; - case 0x1D: - temp_r31->attr ^= 1; + + case 29: + window_ptr->attr ^= 1; break; - case 0xA: - temp_r31->attr &= ~0x2020; - if (temp_r31->attr & 0x200) { - if (!(temp_r31->attr & 0x100)) { - if (HuWinCR(temp_r31) != 0) { - temp_r31->mess++; - HuWinKeyWaitEntry(arg0); - temp_r31->attr |= 2; + + case 10: + window_ptr->attr &= ~0x2020; + if (window_ptr->attr & 0x200) { + if (!(window_ptr->attr & 0x100)) { + if (HuWinCR(window_ptr) != 0) { + window_ptr->mess++; + HuWinKeyWaitEntry(window); + window_ptr->attr |= 2; return; } - if (temp_r31->attr & 0x800) { - sp26 = GetMesMaxSizeSub2(temp_r31, temp_r31->mess + 1); - temp_r31->mess_x = (temp_r31->mess_rect_w - sp26) / 2; - } else if (temp_r31->attr & 0x1000) { - sp26 = GetMesMaxSizeSub2(temp_r31, temp_r31->mess + 1); - temp_r31->mess_x = temp_r31->mess_rect_w - sp26; + if (window_ptr->attr & 0x800) { + mess_w = GetMesMaxSizeSub2(window_ptr, window_ptr->mess + 1); + window_ptr->mess_x = (window_ptr->mess_rect_w - mess_w) / 2; + } else if (window_ptr->attr & 0x1000) { + mess_w = GetMesMaxSizeSub2(window_ptr, window_ptr->mess + 1); + window_ptr->mess_x = window_ptr->mess_rect_w - mess_w; } break; } - sp32 = fontWidthP[16] + temp_r31->spacing_x; + char_w = fontWidthP[16] + window_ptr->spacing_x; /* fallthrough */ - case 0x10: - case 0x20: - temp_r31->attr |= 0x200; - if (temp_r31->mess_x + sp32 > temp_r31->mess_rect_w) { - if (HuWinCR(temp_r31) != 0) { - temp_r31->mess++; - HuWinKeyWaitEntry(arg0); - temp_r31->attr |= 2; + case 16: + case 32: + window_ptr->attr |= 0x200; + if (window_ptr->mess_x + char_w > window_ptr->mess_rect_w) { + if (HuWinCR(window_ptr) != 0) { + window_ptr->mess++; + HuWinKeyWaitEntry(window); + window_ptr->attr |= 2; return; } break; } - temp_r31->mess_x += sp32; + window_ptr->mess_x += char_w; } break; - case 0xE: - temp_r31->attr |= 0x200; - temp_r31->mess++; - sp30 = temp_r31->spacing_x + spcFontTbl[temp_r31->mess[0] - 1].w; - if (temp_r31->mess_x + sp30 > temp_r31->mess_rect_w && HuWinCR(temp_r31) != 0) { - temp_r31->mess--; - HuWinKeyWaitEntry(arg0); - temp_r31->attr |= 2; + + case 14: + window_ptr->attr |= 0x200; + window_ptr->mess++; + tab_w = window_ptr->spacing_x + spcFontTbl[window_ptr->mess[0] - 1].w; + if (window_ptr->mess_x + tab_w > window_ptr->mess_rect_w && HuWinCR(window_ptr) != 0) { + window_ptr->mess--; + HuWinKeyWaitEntry(window); + window_ptr->attr |= 2; return; } - HuWinSpcFontEntry(temp_r31, temp_r31->mess[0] - 1, temp_r31->mess_rect_x + temp_r31->mess_x, temp_r31->mess_rect_y + temp_r31->mess_y); - temp_r31->mess_x += sp30; - sp2C = 1; + HuWinSpcFontEntry(window_ptr, window_ptr->mess[0] - 1, window_ptr->mess_rect_x + window_ptr->mess_x, window_ptr->mess_rect_y + window_ptr->mess_y); + window_ptr->mess_x += tab_w; + mess_end = 1; break; - case 0x1C: - temp_r31->mess++; - HuAudFXPlay(winVoiceTbl[temp_r31->mess[0] - 1]); + + case 28: + window_ptr->mess++; + HuAudFXPlay(winVoiceTbl[window_ptr->mess[0] - 1]); break; - case 0xFF: - temp_r31->mess++; - HuWinKeyWaitEntry(arg0); - temp_r31->attr |= 4; - temp_r31->attr &= ~0x200; + + case 255: + window_ptr->mess++; + HuWinKeyWaitEntry(window); + window_ptr->attr |= 4; + window_ptr->attr &= ~0x200; return; - case 0xF: - temp_r31->attr |= 0x2000; - if (temp_r31->choice_disable[temp_r31->num_choices] != 0) { - temp_r31->attr |= 0x20; - temp_r31->choice_data[temp_r31->num_choices].stat |= 1; + + case 15: + window_ptr->attr |= 0x2000; + if (window_ptr->choice_disable[window_ptr->num_choices] != 0) { + window_ptr->attr |= 0x20; + window_ptr->choice_data[window_ptr->num_choices].stat |= 1; } else { - temp_r31->choice_data[temp_r31->num_choices].stat &= ~1; + window_ptr->choice_data[window_ptr->num_choices].stat &= ~1; } - temp_r31->choice_data[temp_r31->num_choices].x = temp_r31->mess_x + temp_r31->mess_rect_y; - temp_r31->choice_data[temp_r31->num_choices].y = temp_r31->mess_y + temp_r31->mess_rect_x; - temp_r31->num_choices++; + window_ptr->choice_data[window_ptr->num_choices].x = window_ptr->mess_x + window_ptr->mess_rect_y; + window_ptr->choice_data[window_ptr->num_choices].y = window_ptr->mess_y + window_ptr->mess_rect_x; + window_ptr->num_choices++; break; - case 0xC: - temp_r31->attr |= 0x200; - sp30 = temp_r31->char_w * ((temp_r31->mess_x + temp_r31->char_w) / temp_r31->char_w) - temp_r31->mess_x; - if (temp_r31->mess_x + sp30 > temp_r31->mess_rect_w) { - if (HuWinCR(temp_r31) != 0) { - temp_r31->mess++; - HuWinKeyWaitEntry(arg0); - temp_r31->attr |= 2; + + case 12: + window_ptr->attr |= 0x200; + tab_w = window_ptr->tab_w * ((window_ptr->mess_x + window_ptr->tab_w) / window_ptr->tab_w) - window_ptr->mess_x; + if (window_ptr->mess_x + tab_w > window_ptr->mess_rect_w) { + if (HuWinCR(window_ptr) != 0) { + window_ptr->mess++; + HuWinKeyWaitEntry(window); + window_ptr->attr |= 2; return; } } else { - temp_r31->mess_x += sp30; + window_ptr->mess_x += tab_w; } break; } - temp_r31->mess++; - sp32 = temp_r31->spacing_x + fontWidthP[temp_r31->mess[0]]; - if (sp2C != 0) { + window_ptr->mess++; + char_w = window_ptr->spacing_x + fontWidthP[window_ptr->mess[0]]; + if (mess_end != 0) { break; } } - if (sp2C == 0) { - if (temp_r31->mess_x + sp32 > temp_r31->mess_rect_w && HuWinCR(temp_r31) != 0) { - HuWinKeyWaitEntry(arg0); - temp_r31->attr |= 2; + if (mess_end == 0) { + if (window_ptr->mess_x + char_w > window_ptr->mess_rect_w && HuWinCR(window_ptr) != 0) { + HuWinKeyWaitEntry(window); + window_ptr->attr |= 2; return; } - var_r30 = temp_r31->mess[0]; - temp_r31->attr |= 0x200; - if (temp_r31->mess[1] == 0x80) { - if (var_r30 >= 0x96 && var_r30 <= 0xA4) { - var_r30 = var_r30 + 0x6A; - } else if (var_r30 >= 0xAA && var_r30 <= 0xAE) { - var_r30 = var_r30 + 0x65; - } else if (var_r30 >= 0xD6 && var_r30 <= 0xE4) { - var_r30 = var_r30 + 0x43; - } else if (var_r30 >= 0xEA && var_r30 <= 0xEE) { - var_r30 = var_r30 + 0x3E; + c = window_ptr->mess[0]; + window_ptr->attr |= 0x200; + if (window_ptr->mess[1] == 128) { + if (c >= 150 && c <= 164) { + c = c+106; + } else if (c >= 170 && c <= 174) { + c = c+101; + } else if (c >= 214 && c <= 228) { + c = c+67; + } else if (c >= 234 && c <= 238) { + c = c+62; } - temp_r31->mess++; - } else if (temp_r31->mess[1] == 0x81) { - if (var_r30 >= 0xAA && var_r30 <= 0xAE) { - var_r30 = (var_r30 + 0x6A); - } else if (var_r30 >= 0xEA && var_r30 <= 0xEE) { - var_r30 = (var_r30 + 0x43); + window_ptr->mess++; + } else if (window_ptr->mess[1] == 129) { + if (c >= 170 && c <= 174) { + c = c+106; + } else if (c >= 234 && c <= 238) { + c = c+67; } - temp_r31->mess++; + window_ptr->mess++; } - sp28 = (temp_r31->attr & 0x20) ? 8 : temp_r31->mess_color; - if (temp_r31->attr & 1) { - sp2A = 0; - if (temp_r31->mess_color == 0 || temp_r31->mess_color == 1) { - sp2A = 8; + color = (window_ptr->attr & 0x20) ? 8 : window_ptr->mess_color; + if (window_ptr->attr & 1) { + shadow_color = 0; + if (window_ptr->mess_color == 0 || window_ptr->mess_color == 1) { + shadow_color = 8; } - charEntry(arg0, temp_r31->mess_rect_x + temp_r31->mess_x + 2, temp_r31->mess_rect_y + temp_r31->mess_y , var_r30, sp2A); - charEntry(arg0, temp_r31->mess_rect_x + temp_r31->mess_x - 2, temp_r31->mess_rect_y + temp_r31->mess_y , var_r30, sp2A); - charEntry(arg0, temp_r31->mess_rect_x + temp_r31->mess_x , temp_r31->mess_rect_y + temp_r31->mess_y + 2, var_r30, sp2A); - charEntry(arg0, temp_r31->mess_rect_x + temp_r31->mess_x , temp_r31->mess_rect_y + temp_r31->mess_y - 2, var_r30, sp2A); - charEntry(arg0, temp_r31->mess_rect_x + temp_r31->mess_x , temp_r31->mess_rect_y + temp_r31->mess_y , var_r30, sp28); + charEntry(window, window_ptr->mess_rect_x+window_ptr->mess_x+2, window_ptr->mess_rect_y+window_ptr->mess_y, c, shadow_color); + charEntry(window, window_ptr->mess_rect_x+window_ptr->mess_x-2, window_ptr->mess_rect_y+window_ptr->mess_y, c, shadow_color); + charEntry(window, window_ptr->mess_rect_x+window_ptr->mess_x, window_ptr->mess_rect_y+window_ptr->mess_y+2, c, shadow_color); + charEntry(window, window_ptr->mess_rect_x+window_ptr->mess_x, window_ptr->mess_rect_y+window_ptr->mess_y-2, c, shadow_color); + charEntry(window, window_ptr->mess_rect_x+window_ptr->mess_x, window_ptr->mess_rect_y+window_ptr->mess_y, c, color); } else { - charEntry(arg0, temp_r31->mess_rect_x + temp_r31->mess_x + 2, temp_r31->mess_rect_y + temp_r31->mess_y + 2, var_r30, temp_r31->mess_shadow_color); - charEntry(arg0, temp_r31->mess_rect_x + temp_r31->mess_x , temp_r31->mess_rect_y + temp_r31->mess_y , var_r30, sp28); + charEntry(window, window_ptr->mess_rect_x+window_ptr->mess_x+2, window_ptr->mess_rect_y+window_ptr->mess_y+2, c, window_ptr->mess_shadow_color); + charEntry(window, window_ptr->mess_rect_x+window_ptr->mess_x, window_ptr->mess_rect_y+window_ptr->mess_y, c, color); } - temp_r31->mess_x += sp32; - temp_r31->mess++; + window_ptr->mess_x += char_w; + window_ptr->mess++; } } } -static s32 HuWinCR(SomeWindowStruct* arg0) { - if (arg0->mess_y + 0x30 > arg0->mess_rect_h) { - arg0->mess_y = 0; - arg0->mess_x = 0; +static s32 HuWinCR(WindowData *window) { + if (window->mess_y + 48 > window->mess_rect_h) { + window->mess_y = 0; + window->mess_x = 0; return 1; } else { - arg0->mess_y += arg0->spacing_y + 0x18; - arg0->mess_x = 0; + window->mess_y += window->spacing_y + 24; + window->mess_x = 0; return 0; } } -static void _HuWinHomeClear(SomeWindowStruct* arg0) { - s16 var_r30; +static void _HuWinHomeClear(WindowData *window) { + s16 i; - arg0->num_chars = 0; - arg0->mess_y = arg0->mess_x = 0; - arg0->num_choices = 0; - HuWinSpcFontClear(arg0); - arg0->attr &= ~0x2020; - for (var_r30 = 0; var_r30 < 16; var_r30++) { - arg0->choice_data[var_r30].stat = 0; + window->num_chars = 0; + window->mess_y = window->mess_x = 0; + window->num_choices = 0; + HuWinSpcFontClear(window); + window->attr &= ~0x2020; + for (i=0; i<16; i++) { + window->choice_data[i].stat = 0; } } -void HuWinHomeClear(s16 arg0) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +void HuWinHomeClear(s16 window) { + WindowData *window_ptr = &winData[window]; - _HuWinHomeClear(temp_r31); + _HuWinHomeClear(window_ptr); } -void HuWinKeyWaitEntry(s16 arg0) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +void HuWinKeyWaitEntry(s16 window) { + WindowData* window_ptr = &winData[window]; - if (temp_r31->attr & 0x400) { - temp_r31->stat = 0; + if (window_ptr->attr & 0x400) { + window_ptr->stat = 0; } else { - temp_r31->stat = 2; - temp_r31->advance_sprite = HuWinSpcFontEntry(temp_r31, 19, temp_r31->mess_rect_w - 20, temp_r31->mess_rect_h - 24); + window_ptr->stat = 2; + window_ptr->advance_sprite = HuWinSpcFontEntry(window_ptr, 19, window_ptr->mess_rect_w - 20, window_ptr->mess_rect_h - 24); } } -static void HuWinKeyWait(s16 arg0) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +static void HuWinKeyWait(s16 window) { + WindowData* window_ptr = &winData[window]; - if (temp_r31->push_key & HuWinActivePadGet(temp_r31)) { - temp_r31->key_down = HuWinActivePadGet(temp_r31); - temp_r31->stat = 1; + if (window_ptr->push_key & HuWinActivePadGet(window_ptr)) { + window_ptr->key_down = HuWinActivePadGet(window_ptr); + window_ptr->stat = 1; HuAudFXPlay(28); - HuWinSprKill(arg0, temp_r31->advance_sprite); - if (temp_r31->attr & 2) { - _HuWinHomeClear(temp_r31); + HuWinSprKill(window, window_ptr->advance_sprite); + if (window_ptr->attr & 2) { + _HuWinHomeClear(window_ptr); } - temp_r31->attr &= ~2; + window_ptr->attr &= ~2; } } -static s16 HuWinSpcFontEntry(SomeWindowStruct* arg0, s16 arg1, s16 arg2, s16 arg3) { - SpriteGroupData* spC = &HuSprGrpData[arg0->group]; - s16 temp_r3; - s16 var_r30; +static s16 HuWinSpcFontEntry(WindowData *window, s16 entry, s16 x, s16 y) { + SpriteGroupData *group = &HuSprGrpData[window->group]; + s16 sprite; + s16 i; AnimData *anim; - for (var_r30 = 10; var_r30 < 30; var_r30++) { - if (arg0->sprite_id[var_r30] == -1) { - anim = *spcFontTbl[arg1].anim; - arg0->sprite_id[var_r30] = temp_r3 = HuSprCreate(anim, arg0->prio - 1, spcFontTbl[arg1].bank); - HuSprGrpMemberSet(arg0->group, var_r30, temp_r3); - HuSprPosSet(arg0->group, var_r30, arg2 + spcFontTbl[arg1].center_x - arg0->w / 2, arg3 + spcFontTbl[arg1].center_y - arg0->h / 2); + for (i=10; i<30; i++) { + if (window->sprite_id[i] == -1) { + anim = *spcFontTbl[entry].anim; + window->sprite_id[i] = sprite = HuSprCreate(anim, window->prio-1, spcFontTbl[entry].bank); + HuSprGrpMemberSet(window->group, i, sprite); + HuSprPosSet(window->group, i, x + spcFontTbl[entry].center_x - window->w / 2, y + spcFontTbl[entry].center_y - window->h / 2); break; } } - return var_r30; + return i; } -static void HuWinSpcFontPosSet(SomeWindowStruct* arg0, s16 arg1, s16 arg2, s16 arg3) { - SpriteGroupData* temp_var = &HuSprGrpData[arg0->group]; +static void HuWinSpcFontPosSet(WindowData *window, s16 index, s16 x, s16 y) { + SpriteGroupData *group = &HuSprGrpData[window->group]; - HuSprPosSet(arg0->group, arg1, arg2 - arg0->w / 2, arg3 - arg0->h / 2); + HuSprPosSet(window->group, index, x - window->w / 2, y - window->h / 2); } -static void HuWinSpcFontClear(SomeWindowStruct* arg0) { - s16 var_r31; +static void HuWinSpcFontClear(WindowData* window) { + s16 i; - for (var_r31 = 10; var_r31 < 30; var_r31++) { - if (arg0->sprite_id[var_r31] != -1) { - HuSprGrpMemberKill(arg0->group, var_r31); - arg0->sprite_id[var_r31] = -1; + for (i=10; i<30; i++) { + if (window->sprite_id[i] != -1) { + HuSprGrpMemberKill(window->group, i); + window->sprite_id[i] = -1; } } } +static void HuWinChoice(WindowData *window) { + WinChoice *choice; + f32 choice_dist; + f32 min_choice_dist_x; + s16 choice_dist_y; + s16 key; + s16 choice_curr_x; + s16 choice_curr_y; + s16 choice_curr; + s16 choice_max; + s16 choice_dist_x; + s16 dir; + s16 choice_y; + s16 choice_next; + s16 i; -void HuWinChoice(SomeWindowStruct* arg0) { - WinChoice *var_r31; - f32 var_f30; - f32 var_f31; - s16 temp_r20; - s16 temp_r21; - s16 temp_r25; - s16 temp_r24; - s16 temp_r26; - s16 temp_r27; - s16 temp_r28; - s16 var_r19; - s16 var_r22; - s16 var_r23; - s16 var_r30; - - temp_r26 = arg0->choice; - var_r23 = temp_r26; - var_r19 = -1; - temp_r21 = HuWinActivePadGet(arg0); - if (temp_r21 & 1) { - var_r19 = 0; + choice_curr = window->choice; + choice_next = choice_curr; + dir = -1; + key = HuWinActivePadGet(window); + if (key & 1) { + dir = 0; } - if (temp_r21 & 2) { - var_r19 = 2; + if (key & 2) { + dir = 2; } - if (temp_r21 & 8) { - var_r19 = 1; + if (key & 8) { + dir = 1; } - if (temp_r21 & 4) { - var_r19 = 3; + if (key & 4) { + dir = 3; } - temp_r25 = arg0->choice_data[temp_r26].x; - temp_r24 = arg0->choice_data[temp_r26].y; - var_f31 = 100000.0f; - var_f30 = var_f31; - temp_r27 = arg0->num_choices; - switch (var_r19) { + choice_curr_x = window->choice_data[choice_curr].x; + choice_curr_y = window->choice_data[choice_curr].y; + min_choice_dist_x = 100000.0f; + choice_dist = min_choice_dist_x; + choice_max = window->num_choices; + switch (dir) { case 0: - for (var_r30 = 0, var_r31 = arg0->choice_data; var_r30 < temp_r27; var_r30++, var_r31++) { - if (var_r30 != temp_r26 && !(var_r31->stat & 1) && var_r31->y == temp_r24 && var_r31->x < temp_r25) { + for (i = 0, choice = window->choice_data; i < choice_max; i++, choice++) { + if (i != choice_curr && !(choice->stat & 1) && choice->y == choice_curr_y && choice->x < choice_curr_x) { break; } } - if (var_r30 != temp_r27) { - for (var_r30 = 0, var_r31 = arg0->choice_data; var_r30 < temp_r27; var_r30++, var_r31++) { - if (var_r30 != temp_r26 && !(var_r31->stat & 1) && var_r31->y == temp_r24 && var_r31->x < temp_r25 && var_f30 > temp_r25 - var_r31->x) { - var_f30 = temp_r25 - var_r31->x; - var_r23 = var_r30; + if (i != choice_max) { + for (i = 0, choice = window->choice_data; i < choice_max; i++, choice++) { + if (i != choice_curr && !(choice->stat & 1) && choice->y == choice_curr_y && choice->x < choice_curr_x && choice_dist > choice_curr_x - choice->x) { + choice_dist = choice_curr_x - choice->x; + choice_next = i; } } } break; case 1: - for (var_r30 = 0, var_r31 = arg0->choice_data; var_r30 < temp_r27; var_r30++, var_r31++) { - if (var_r30 != temp_r26 && !(var_r31->stat & 1) && var_r31->y < temp_r24) { + for (i = 0, choice = window->choice_data; i < choice_max; i++, choice++) { + if (i != choice_curr && !(choice->stat & 1) && choice->y < choice_curr_y) { break; } } - if (var_r30 != temp_r27) { - for (var_r30 = 0, var_r31 = arg0->choice_data; var_r30 < temp_r27; var_r30++, var_r31++) { - if (var_r30 != temp_r26 && !(var_r31->stat & 1) && var_r31->y < temp_r24) { - temp_r20 = temp_r24 - var_r31->y; - if (temp_r20 <= var_f30) { - if (temp_r20 < var_f30) { - var_f31 = 100000.0f; + if (i != choice_max) { + for (i = 0, choice = window->choice_data; i < choice_max; i++, choice++) { + if (i != choice_curr && !(choice->stat & 1) && choice->y < choice_curr_y) { + choice_dist_y = choice_curr_y - choice->y; + if (choice_dist_y <= choice_dist) { + if (choice_dist_y < choice_dist) { + min_choice_dist_x = 100000.0f; } - temp_r28 = temp_r25 - var_r31->x; - temp_r28 = temp_r28 * temp_r28; - if (temp_r28 < var_f31) { - var_f30 = temp_r20; - var_f31 = temp_r28; - var_r23 = var_r30; + choice_dist_x = choice_curr_x - choice->x; + choice_dist_x = choice_dist_x * choice_dist_x; + if (choice_dist_x < min_choice_dist_x) { + choice_dist = choice_dist_y; + min_choice_dist_x = choice_dist_x; + choice_next = i; } } } } } else { - var_r22 = -1000; - for (var_r30 = 0, var_r31 = arg0->choice_data; var_r30 < temp_r27; var_r30++, var_r31++) { - if (var_r30 != temp_r26 && !(var_r31->stat & 1) && var_r31->y > var_r22) { - var_r22 = var_r31->y; + choice_y = -1000; + for (i = 0, choice = window->choice_data; i < choice_max; i++, choice++) { + if (i != choice_curr && !(choice->stat & 1) && choice->y > choice_y) { + choice_y = choice->y; } } - if (var_r22 != temp_r24) { - var_f31 = 100000.0f; - for (var_r30 = 0, var_r31 = arg0->choice_data; var_r30 < temp_r27; var_r30++, var_r31++) { - if (var_r30 != temp_r26 && !(var_r31->stat & 1) && var_r31->y == var_r22) { - temp_r28 = temp_r25 - var_r31->x; - temp_r28 = temp_r28 * temp_r28; - if (temp_r28 < var_f31) { - var_f31 = temp_r28; - var_r23 = var_r30; + if (choice_y != choice_curr_y) { + min_choice_dist_x = 100000.0f; + for (i = 0, choice = window->choice_data; i < choice_max; i++, choice++) { + if (i != choice_curr && !(choice->stat & 1) && choice->y == choice_y) { + choice_dist_x = choice_curr_x - choice->x; + choice_dist_x = choice_dist_x * choice_dist_x; + if (choice_dist_x < min_choice_dist_x) { + min_choice_dist_x = choice_dist_x; + choice_next = i; } } } @@ -1023,60 +1032,60 @@ void HuWinChoice(SomeWindowStruct* arg0) { } break; case 2: - for (var_r30 = 0, var_r31 = arg0->choice_data; var_r30 < temp_r27; var_r30++, var_r31++) { - if (var_r30 != temp_r26 && !(var_r31->stat & 1) && var_r31->y == temp_r24 && var_r31->x > temp_r25) { + for (i = 0, choice = window->choice_data; i < choice_max; i++, choice++) { + if (i != choice_curr && !(choice->stat & 1) && choice->y == choice_curr_y && choice->x > choice_curr_x) { break; } } - if (var_r30 != temp_r27) { - for (var_r30 = 0, var_r31 = arg0->choice_data; var_r30 < temp_r27; var_r30++, var_r31++) { - if (var_r30 != temp_r26 && !(var_r31->stat & 1) && var_r31->y == temp_r24 && var_r31->x > temp_r25 && var_f30 > var_r31->x - temp_r25) { - var_f30 = var_r31->x - temp_r25; - var_r23 = var_r30; + if (i != choice_max) { + for (i = 0, choice = window->choice_data; i < choice_max; i++, choice++) { + if (i != choice_curr && !(choice->stat & 1) && choice->y == choice_curr_y && choice->x > choice_curr_x && choice_dist > choice->x - choice_curr_x) { + choice_dist = choice->x - choice_curr_x; + choice_next = i; } } } break; case 3: - for (var_r30 = 0, var_r31 = arg0->choice_data; var_r30 < temp_r27; var_r30++, var_r31++) { - if (var_r30 != temp_r26 && !(var_r31->stat & 1) && var_r31->y > temp_r24) { + for (i = 0, choice = window->choice_data; i < choice_max; i++, choice++) { + if (i != choice_curr && !(choice->stat & 1) && choice->y > choice_curr_y) { break; } } - if (var_r30 != temp_r27) { - for (var_r30 = 0, var_r31 = arg0->choice_data; var_r30 < temp_r27; var_r30++, var_r31++) { - if (var_r30 != temp_r26 && !(var_r31->stat & 1) && var_r31->y > temp_r24) { - temp_r20 = var_r31->y - temp_r24; - if (temp_r20 <= var_f30) { - if (temp_r20 < var_f30) { - var_f31 = 100000.0f; + if (i != choice_max) { + for (i = 0, choice = window->choice_data; i < choice_max; i++, choice++) { + if (i != choice_curr && !(choice->stat & 1) && choice->y > choice_curr_y) { + choice_dist_y = choice->y - choice_curr_y; + if (choice_dist_y <= choice_dist) { + if (choice_dist_y < choice_dist) { + min_choice_dist_x = 100000.0f; } - temp_r28 = temp_r25 - var_r31->x; - temp_r28 = temp_r28 * temp_r28; - if (temp_r28 < var_f31) { - var_f30 = temp_r20; - var_f31 = temp_r28; - var_r23 = var_r30; + choice_dist_x = choice_curr_x - choice->x; + choice_dist_x = choice_dist_x * choice_dist_x; + if (choice_dist_x < min_choice_dist_x) { + choice_dist = choice_dist_y; + min_choice_dist_x = choice_dist_x; + choice_next = i; } } } } } else { - var_r22 = 1000; - for (var_r30 = 0, var_r31 = arg0->choice_data; var_r30 < temp_r27; var_r30++, var_r31++) { - if (var_r30 != temp_r26 && !(var_r31->stat & 1) && var_r31->y < var_r22) { - var_r22 = var_r31->y; + choice_y = 1000; + for (i = 0, choice = window->choice_data; i < choice_max; i++, choice++) { + if (i != choice_curr && !(choice->stat & 1) && choice->y < choice_y) { + choice_y = choice->y; } } - if (var_r22 != temp_r24) { - var_f31 = 100000.0f; - for (var_r30 = 0, var_r31 = arg0->choice_data; var_r30 < temp_r27; var_r30++, var_r31++) { - if (var_r30 != temp_r26 && !(var_r31->stat & 1) && var_r31->y == var_r22) { - temp_r28 = temp_r25 - var_r31->x; - temp_r28 = temp_r28 * temp_r28; - if (temp_r28 < var_f31) { - var_f31 = temp_r28; - var_r23 = var_r30; + if (choice_y != choice_curr_y) { + min_choice_dist_x = 100000.0f; + for (i = 0, choice = window->choice_data; i < choice_max; i++, choice++) { + if (i != choice_curr && !(choice->stat & 1) && choice->y == choice_y) { + choice_dist_x = choice_curr_x - choice->x; + choice_dist_x = choice_dist_x * choice_dist_x; + if (choice_dist_x < min_choice_dist_x) { + min_choice_dist_x = choice_dist_x; + choice_next = i; } } } @@ -1084,424 +1093,424 @@ void HuWinChoice(SomeWindowStruct* arg0) { } break; } - if (arg0->choice != var_r23) { - arg0->choice = var_r23; + if (window->choice != choice_next) { + window->choice = choice_next; HuAudFXPlay(0); - } else if (temp_r21 & (arg0->key_auto | 0x100)) { + } else if (key & (window->key_auto | 0x100)) { HuAudFXPlay(2); - arg0->key_down = temp_r21; - arg0->stat = 0; - } else if ((temp_r21 & 0x200) && !(arg0->attr & 0x10)) { + window->key_down = key; + window->stat = 0; + } else if ((key & 0x200) && !(window->attr & 0x10)) { HuAudFXPlay(3); - arg0->key_down = temp_r21; - arg0->choice = -1; - arg0->stat = 0; + window->key_down = key; + window->choice = -1; + window->stat = 0; } - HuWinSpcFontPosSet(arg0, arg0->cursor_sprite, arg0->choice_data[var_r23].x + spcFontTbl[20].center_x, arg0->choice_data[var_r23].y + spcFontTbl[20].center_y); + HuWinSpcFontPosSet(window, window->cursor_sprite, window->choice_data[choice_next].x + spcFontTbl[20].center_x, window->choice_data[choice_next].y + spcFontTbl[20].center_y); } -u32 HuWinActivePadGet(SomeWindowStruct* arg0) { - s32 var_r30; - u32 var_r31; +u32 HuWinActivePadGet(WindowData *window) { + s32 win_key; + u32 i; - var_r30 = 0; - for (var_r31 = 0; var_r31 < 4; var_r31++) { - if (arg0->active_pad & (1 << var_r31)) { - var_r30 |= winKey[var_r31]; + win_key = 0; + for (i=0; i<4; i++) { + if (window->active_pad & (1 << i)) { + win_key |= winKey[i]; } } - return var_r30; + return win_key; } -u32 HuWinActiveKeyGetX(SomeWindowStruct* arg0) { - u32 var_r29; - u32 var_r30; - u32 var_r31; - u8 temp_r28; +u32 HuWinActiveKeyGetX(WindowData *window) { + u32 button; + u32 i; + u32 j; + u8 active_pad; - var_r29 = 0; - temp_r28 = (arg0->active_pad & ~arg0->player_disable); - for (var_r30 = 0; var_r30 < 4; var_r30++) { - if (temp_r28 & (1 << var_r30)) { - for (var_r31 = 0; var_r31 < 4; var_r31++) { - if (var_r30 == GWPlayerCfg[var_r31].pad_idx) { + button = 0; + active_pad = (window->active_pad & ~window->player_disable); + for (i = 0; i < 4; i++) { + if (active_pad & (1 << i)) { + for (j=0; j<4; j++) { + if (i == GWPlayerCfg[j].pad_idx) { break; } } - if (var_r31 != 4 && GWPlayerCfg[var_r31].iscom == 0) { - var_r29 |= HuPadBtn[GWPlayerCfg[var_r31].pad_idx]; + if (j != 4 && GWPlayerCfg[j].iscom == 0) { + button |= HuPadBtn[GWPlayerCfg[j].pad_idx]; } } } - return var_r29; + return button; } -void HuWinPosSet(s16 arg0, f32 arg1, f32 arg2) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +void HuWinPosSet(s16 window, f32 x, f32 y) { + WindowData *window_ptr = &winData[window]; - temp_r31->pos_x = arg1; - temp_r31->pos_y = arg2; - HuSprGrpPosSet(temp_r31->group, arg1, arg2); + window_ptr->pos_x = x; + window_ptr->pos_y = y; + HuSprGrpPosSet(window_ptr->group, x, y); } -void HuWinScaleSet(s16 arg0, f32 arg1, f32 arg2) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +void HuWinScaleSet(s16 window, f32 x, f32 y) { + WindowData *window_ptr = &winData[window]; - temp_r31->scale_x = arg1; - temp_r31->scale_y = arg2; - HuSprGrpScaleSet(temp_r31->group, arg1, arg2); + window_ptr->scale_x = x; + window_ptr->scale_y = y; + HuSprGrpScaleSet(window_ptr->group, x, y); } -void HuWinZRotSet(s16 arg0, f32 arg1) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +void HuWinZRotSet(s16 window, f32 rot) { + WindowData *window_ptr = &winData[window]; - temp_r31->rot = arg1; - HuSprGrpZRotSet(temp_r31->group, arg1); + window_ptr->rot = rot; + HuSprGrpZRotSet(window_ptr->group, rot); } -void HuWinCenterPosSet(s16 arg0, f32 arg1, f32 arg2) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +void HuWinCenterPosSet(s16 window, f32 x, f32 y) { + WindowData *window_ptr = &winData[window]; - HuSprGrpCenterSet(temp_r31->group, temp_r31->w / 2.0f - arg1, temp_r31->h / 2.0f - arg2); + HuSprGrpCenterSet(window_ptr->group, window_ptr->w / 2.0f - x, window_ptr->h / 2.0f - y); } -void HuWinDrawNoSet(s16 arg0, s16 arg1) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +void HuWinDrawNoSet(s16 window, s16 draw_no) { + WindowData *window_ptr = &winData[window]; - HuSprGrpDrawNoSet(temp_r31->group, arg1); + HuSprGrpDrawNoSet(window_ptr->group, draw_no); } -void HuWinScissorSet(s16 arg0, s16 arg1, s16 arg2, s16 arg3, s16 arg4) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +void HuWinScissorSet(s16 window, s16 x, s16 y, s16 w, s16 h) { + WindowData *window_ptr = &winData[window]; - HuSprGrpScissorSet(temp_r31->group, arg1, arg2, arg3, arg4); + HuSprGrpScissorSet(window_ptr->group, x, y, w, h); } -void HuWinPriSet(s16 arg0, s16 arg1) { - SomeWindowStruct* temp_r31 = &winData[arg0]; - s16 var_r30; +void HuWinPriSet(s16 window, s16 prio) { + WindowData *window_ptr = &winData[window]; + s16 i; - HuSprPriSet(temp_r31->group, 0, arg1); - HuSprPriSet(temp_r31->group, 1, arg1); - for (var_r30 = 2; var_r30 < 30; var_r30++) { - if (temp_r31->sprite_id[var_r30] != -1) { - HuSprPriSet(temp_r31->group, var_r30, arg1 - 1); + HuSprPriSet(window_ptr->group, 0, prio); + HuSprPriSet(window_ptr->group, 1, prio); + for (i=2; i<30; i++) { + if (window_ptr->sprite_id[i] != -1) { + HuSprPriSet(window_ptr->group, i, prio - 1); } } - temp_r31->prio = arg1; + window_ptr->prio = prio; } -void HuWinAttrSet(s16 arg0, s32 arg1) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +void HuWinAttrSet(s16 window, s32 attr) { + WindowData *window_ptr = &winData[window]; - temp_r31->attr |= arg1; + window_ptr->attr |= attr; } -void HuWinAttrReset(s16 arg0, u32 arg1) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +void HuWinAttrReset(s16 window, u32 attr) { + WindowData *window_ptr = &winData[window]; - temp_r31->attr &= ~arg1; + window_ptr->attr &= ~attr; } -u8 HuWinStatGet(s16 arg0) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +u8 HuWinStatGet(s16 window) { + WindowData *window_ptr = &winData[window]; - return temp_r31->stat; + return window_ptr->stat; } -void HuWinMesColSet(s16 arg0, u8 arg1) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +void HuWinMesColSet(s16 window, u8 color) { + WindowData *window_ptr = &winData[window]; - temp_r31->mess_color = arg1; - temp_r31->attr |= 0x80; + window_ptr->mess_color = color; + window_ptr->attr |= 0x80; } -void HuWinMesPalSet(s16 arg0, u8 arg1, u8 arg2, u8 arg3, u8 arg4) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +void HuWinMesPalSet(s16 window, u8 index, u8 r, u8 g, u8 b) { + WindowData *window_ptr = &winData[window]; - temp_r31->mess_pal[arg1][0] = arg2; - temp_r31->mess_pal[arg1][1] = arg3; - temp_r31->mess_pal[arg1][2] = arg4; + window_ptr->mess_pal[index][0] = r; + window_ptr->mess_pal[index][1] = g; + window_ptr->mess_pal[index][2] = b; } -void HuWinBGTPLvlSet(s16 arg0, f32 arg1) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +void HuWinBGTPLvlSet(s16 window, f32 tp_level) { + WindowData *window_ptr = &winData[window]; - HuSprTPLvlSet(temp_r31->group, 0, arg1); + HuSprTPLvlSet(window_ptr->group, 0, tp_level); } -void HuWinBGColSet(s16 arg0, GXColor *arg1) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +void HuWinBGColSet(s16 window, GXColor *bg_color) { + WindowData *window_ptr = &winData[window]; - HuSprColorSet(temp_r31->group, 0, arg1->r, arg1->g, arg1->b); + HuSprColorSet(window_ptr->group, 0, bg_color->r, bg_color->g, bg_color->b); } -void HuWinMesSpeedSet(s16 arg0, s16 arg1) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +void HuWinMesSpeedSet(s16 window, s16 speed) { + WindowData *window_ptr = &winData[window]; - temp_r31->speed = arg1; + window_ptr->speed = speed; } -void HuWinMesRead(s32 arg0) { - void* temp_r31; - char* var_r30; +void HuWinMesRead(s32 mess_data_no) { + void *dvd_mess; + char *mess_path; - if (messDataPtr != 0) { + if(messDataPtr) { HuMemDirectFree(messDataPtr); } - messDataNo = arg0; + messDataNo = mess_data_no; if (LanguageNo == 0) { - var_r30 = mesDataTbl[messDataNo]; + mess_path = mesDataTbl[messDataNo]; } else { - var_r30 = mesDataTbl[messDataNo + 2]; + mess_path = mesDataTbl[messDataNo + 2]; } - temp_r31 = HuDvdDataRead(var_r30); + dvd_mess = HuDvdDataRead(mess_path); messDataPtr = HuMemDirectMalloc(HEAP_SYSTEM, DirDataSize); - memcpy(messDataPtr, temp_r31, DirDataSize); - HuMemDirectFree(temp_r31); + memcpy(messDataPtr, dvd_mess, DirDataSize); + HuMemDirectFree(dvd_mess); } -void HuWinMesSet(s16 arg0, u32 arg1) { - SomeWindowStruct* win = &winData[arg0]; +void HuWinMesSet(s16 window, u32 mess) { + WindowData *window_ptr = &winData[window]; - win->stat = 1; - if ((arg1 & 0x80000000) == 0) { + window_ptr->stat = 1; + if ((mess & 0x80000000) == 0) { if (messDataPtr == 0) { OSReport("Error: No Message\n"); return; } - win->mess = MessData_MesPtrGet(messDataPtr, arg1); - if (win->mess == 0) { + window_ptr->mess = MessData_MesPtrGet(messDataPtr, mess); + if (window_ptr->mess == 0) { OSReport("Error: No Message data\n"); - HuWinMesSet(arg0, 0); + HuWinMesSet(window, 0); return; } } else { - win->mess = (u8*) arg1; + window_ptr->mess = (u8 *)mess; } - if (!(win->attr & 0x80)) { - win->mess_color = 7; - win->mess_time = 0; + if (!(window_ptr->attr & 0x80)) { + window_ptr->mess_color = 7; + window_ptr->mess_time = 0; } } -void HuWinInsertMesSet(s16 arg0, u32 arg1, s16 arg2) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +void HuWinInsertMesSet(s16 window, u32 mess, s16 index) { + WindowData *window_ptr = &winData[window]; - if (!(arg1 & 0x80000000)) { + if (!(mess & 0x80000000)) { if (messDataPtr == 0) { OSReport("Error: No Message\n"); return; } - temp_r31->insert_mess[arg2] = MessData_MesPtrGet(messDataPtr, arg1); - if (temp_r31->insert_mess[arg2] == 0) { + window_ptr->insert_mess[index] = MessData_MesPtrGet(messDataPtr, mess); + if (window_ptr->insert_mess[index] == 0) { OSReport("Error: No Message data\n"); } } else { - temp_r31->insert_mess[arg2] = (void*) arg1; + window_ptr->insert_mess[index] = (u8 *)mess; } } -s16 HuWinChoiceGet(s16 arg0, s16 arg1) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +s16 HuWinChoiceGet(s16 window, s16 start_choice) { + WindowData *window_ptr = &winData[window]; - temp_r31->attr |= 0x40; - while (temp_r31->stat != 0) { + window_ptr->attr |= 0x40; + while (window_ptr->stat != 0) { HuPrcVSleep(); } - for (; arg1 < temp_r31->num_choices; arg1++) { - if (!(temp_r31->choice_data[arg1].stat & 1)) { + for (; start_choice < window_ptr->num_choices; start_choice++) { + if (!(window_ptr->choice_data[start_choice].stat & 1)) { break; } } - if (arg1 == temp_r31->num_choices) { - for (arg1 = 0; arg1 < temp_r31->num_choices; arg1++) { - if (!(temp_r31->choice_data[arg1].stat & 1)) { + if (start_choice == window_ptr->num_choices) { + for (start_choice = 0; start_choice < window_ptr->num_choices; start_choice++) { + if (!(window_ptr->choice_data[start_choice].stat & 1)) { break; } } - if (arg1 == temp_r31->num_choices) { + if (start_choice == window_ptr->num_choices) { return -1; } } - temp_r31->cursor_sprite = HuWinSpcFontEntry(temp_r31, 0x14, temp_r31->choice_data[arg1].x, temp_r31->choice_data[arg1].y); - temp_r31->stat = 3; - temp_r31->choice = arg1; - while (temp_r31->stat != 0) { + window_ptr->cursor_sprite = HuWinSpcFontEntry(window_ptr, 0x14, window_ptr->choice_data[start_choice].x, window_ptr->choice_data[start_choice].y); + window_ptr->stat = 3; + window_ptr->choice = start_choice; + while (window_ptr->stat != 0) { HuPrcVSleep(); } - return temp_r31->choice; + return window_ptr->choice; } -s16 HuWinChoiceNumGet(s16 arg0) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +s16 HuWinChoiceNumGet(s16 window) { + WindowData *window_ptr = &winData[window]; - return temp_r31->num_choices; + return window_ptr->num_choices; } -void HuWinChoiceDisable(s16 arg0, s16 arg1) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +void HuWinChoiceDisable(s16 window, s16 choice) { + WindowData *window_ptr = &winData[window]; - temp_r31->choice_disable[arg1] = 1; + window_ptr->choice_disable[choice] = 1; } -s16 HuWinChoiceNowGet(s16 arg0) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +s16 HuWinChoiceNowGet(s16 window) { + WindowData *window_ptr = &winData[window]; - if (temp_r31->stat == 3) { - return temp_r31->choice; + if (window_ptr->stat == 3) { + return window_ptr->choice; } else { return -1; } } -void HuWinMesWait(s16 arg0) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +void HuWinMesWait(s16 window) { + WindowData *window_ptr = &winData[window]; - while (temp_r31->stat != 0) { + while(window_ptr->stat != 0) { HuPrcVSleep(); } } -void HuWinAnimSet(s16 arg0, AnimData* arg1, s16 arg2, f32 arg3, f32 arg4) { - SomeWindowStruct* temp_r31 = &winData[arg0]; - s16 temp_r30; +void HuWinAnimSet(s16 window, AnimData *anim, s16 bank, f32 x, f32 y) { + WindowData *window_ptr = &winData[window]; + s16 sprite; - temp_r30 = HuSprCreate(arg1, temp_r31->prio - 1, arg2); - HuWinSprSet(arg0, temp_r30, arg3, arg4); + sprite = HuSprCreate(anim, window_ptr->prio-1, bank); + HuWinSprSet(window, sprite, x, y); } -s16 HuWinSprSet(s16 arg0, s16 arg1, f32 arg2, f32 arg3) { - SomeWindowStruct* temp_r31 = &winData[arg0]; - SpriteGroupData* temp_r29 = &HuSprGrpData[temp_r31->group]; - s16 var_r30; +s16 HuWinSprSet(s16 window, s16 sprite, f32 x, f32 y) { + WindowData *window_ptr = &winData[window]; + SpriteGroupData *group = &HuSprGrpData[window_ptr->group]; + s16 i; - for (var_r30 = 2; var_r30 <= 9; var_r30++) { - if (temp_r31->sprite_id[var_r30] == -1) { - temp_r31->sprite_id[var_r30] = arg1; - HuSprGrpMemberSet(temp_r31->group, var_r30, arg1); - HuSprPosSet(temp_r31->group, var_r30, arg2 - temp_r29->center_x, arg3 - temp_r29->center_y); + for (i=2; i<=9; i++) { + if (window_ptr->sprite_id[i] == -1) { + window_ptr->sprite_id[i] = sprite; + HuSprGrpMemberSet(window_ptr->group, i, sprite); + HuSprPosSet(window_ptr->group, i, x - group->center_x, y - group->center_y); break; } } - return var_r30; + return i; } -void HuWinSprPosSet(s16 arg0, s16 arg1, f32 arg2, f32 arg3) { - SomeWindowStruct* temp_r31 = &winData[arg0]; - SpriteGroupData* temp_r30 = &HuSprGrpData[temp_r31->group]; +void HuWinSprPosSet(s16 window, s16 sprite, f32 x, f32 y) { + WindowData *window_ptr = &winData[window]; + SpriteGroupData *group = &HuSprGrpData[window_ptr->group]; - HuSprPosSet(temp_r31->group, arg1, arg2 - temp_r30->center_x, arg3 - temp_r30->center_y); + HuSprPosSet(window_ptr->group, sprite, x - group->center_x, y - group->center_y); } -void HuWinSprPriSet(s16 arg0, s16 arg1, s16 arg2) { - SomeWindowStruct* temp_r31 = &winData[arg0]; - SpriteGroupData* sp10 = &HuSprGrpData[temp_r31->group]; +void HuWinSprPriSet(s16 window, s16 sprite, s16 prio) { + WindowData *window_ptr = &winData[window]; + SpriteGroupData *group = &HuSprGrpData[window_ptr->group]; - HuSprPriSet(temp_r31->group, arg1, arg2); + HuSprPriSet(window_ptr->group, sprite, prio); } -s16 HuWinSprIDGet(s16 arg0, s16 arg1) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +s16 HuWinSprIDGet(s16 window, s16 index) { + WindowData *window_ptr = &winData[window]; - return temp_r31->sprite_id[arg1]; + return window_ptr->sprite_id[index]; } -void HuWinSprKill(s16 arg0, s16 arg1) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +void HuWinSprKill(s16 window, s16 sprite) { + WindowData *window_ptr = &winData[window]; - HuSprGrpMemberKill(temp_r31->group, arg1); - temp_r31->sprite_id[arg1] = -1; + HuSprGrpMemberKill(window_ptr->group, sprite); + window_ptr->sprite_id[sprite] = -1; } -void HuWinDispOff(s16 arg0) { - SomeWindowStruct* temp_r31 = &winData[arg0]; - s16 var_r30; +void HuWinDispOff(s16 window) { + WindowData *window_ptr = &winData[window]; + s16 i; - for (var_r30 = 0; var_r30 < 30; var_r30++) { - if (temp_r31->sprite_id[var_r30] != -1) { - HuSprAttrSet(temp_r31->group, var_r30, 4); + for(i=0; i<30; i++) { + if (window_ptr->sprite_id[i] != -1) { + HuSprAttrSet(window_ptr->group, i, SPRITE_ATTR_HIDDEN); } } - temp_r31->attr |= 8; + window_ptr->attr |= 8; } -void HuWinDispOn(s16 arg0) { - SomeWindowStruct* temp_r31 = &winData[arg0]; - s16 var_r30; +void HuWinDispOn(s16 window) { + WindowData *window_ptr = &winData[window]; + s16 i; - for (var_r30 = 0; var_r30 < 30; var_r30++) { - if (temp_r31->sprite_id[var_r30] != -1) { - HuSprAttrReset(temp_r31->group, var_r30, 4); + for (i=0; i<30; i++) { + if (window_ptr->sprite_id[i] != -1) { + HuSprAttrReset(window_ptr->group, i, SPRITE_ATTR_HIDDEN); } } - temp_r31->attr = temp_r31->attr & ~8; + window_ptr->attr = window_ptr->attr & ~8; } -void HuWinComKeyWait(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s16 arg4) { - s32 var_r31; - s32 var_r30; - s32 var_r29; - s32 var_r28; +void HuWinComKeyWait(s32 player_1, s32 player_2, s32 player_3, s32 player_4, s16 delay) { + s32 wait_input_p4; + s32 wait_input_p3; + s32 wait_input_p2; + s32 wait_input_p1; - if (arg3 == -1) { - var_r31 = -1; + if (player_4 == -1) { + wait_input_p4 = -1; } else { - var_r31 = 0; + wait_input_p4 = 0; } - if (arg2 == -1) { - var_r30 = -1; + if (player_3 == -1) { + wait_input_p3 = -1; } else { - var_r30 = 0; + wait_input_p3 = 0; } - if (arg1 == -1) { - var_r29 = -1; + if (player_2 == -1) { + wait_input_p2 = -1; } else { - var_r29 = 0; + wait_input_p2 = 0; } - if (arg0 == -1) { - var_r28 = -1; + if (player_1 == -1) { + wait_input_p1 = -1; } else { - var_r28 = 0; + wait_input_p1 = 0; } - _HuWinComKeySet(var_r28, var_r29, var_r30, var_r31, arg4); - _HuWinComKeySet(arg0, arg1, arg2, arg3, 1); + _HuWinComKeySet(wait_input_p1, wait_input_p2, wait_input_p3, wait_input_p4, delay); + _HuWinComKeySet(player_1, player_2, player_3, player_4, 1); } -void HuWinComKeySet(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - _HuWinComKeySet(arg0, arg1, arg2, arg3, 1); +void HuWinComKeySet(s32 player_1, s32 player_2, s32 player_3, s32 player_4) { + _HuWinComKeySet(player_1, player_2, player_3, player_4, 1); } -void _HuWinComKeySet(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s16 arg4) { - winComKeyBuf[comKeyIdx].player[0] = arg0; - winComKeyBuf[comKeyIdx].player[1] = arg1; - winComKeyBuf[comKeyIdx].player[2] = arg2; - winComKeyBuf[comKeyIdx].player[3] = arg3; - winComKeyBuf[comKeyIdx].time = arg4; +void _HuWinComKeySet(s32 player_1, s32 player_2, s32 player_3, s32 player_4, s16 delay) { + winComKeyBuf[comKeyIdx].player[0] = player_1; + winComKeyBuf[comKeyIdx].player[1] = player_2; + winComKeyBuf[comKeyIdx].player[2] = player_3; + winComKeyBuf[comKeyIdx].player[3] = player_4; + winComKeyBuf[comKeyIdx].time = delay; comKeyIdx++; comKeyIdx &= 0xFF; } -void HuWinComKeyGet(s16 arg0, u32* arg1) { - SomeWindowStruct* temp_r30 = &winData[arg0]; - s16 var_r31; +void HuWinComKeyGet(s16 window, u32 *data) { + WindowData *window_ptr = &winData[window]; + s16 i; if (comKeyIdx == comKeyIdxNow) { - for (var_r31 = 0; var_r31 < 4; var_r31++) { - if (!(temp_r30->player_disable & (1 << var_r31))) { - arg1[var_r31] = HuPadDStkRep[var_r31] | HuPadBtnDown[var_r31]; + for (i=0; i<4; i++) { + if (!(window_ptr->player_disable & (1 << i))) { + data[i] = HuPadDStkRep[i] | HuPadBtnDown[i]; } else { - arg1[var_r31] = 0; + data[i] = 0; } } } else { - for (var_r31 = 0; var_r31 < 4; var_r31++) { - arg1[var_r31] = winComKeyBuf[comKeyIdxNow].player[var_r31]; - if (arg1[var_r31] == 0xFFFFFFFF) { - if (!(temp_r30->player_disable & (1 << var_r31))) { - arg1[var_r31] = HuPadDStkRep[var_r31] | HuPadBtnDown[var_r31]; + for (i=0; i<4; i++) { + data[i] = winComKeyBuf[comKeyIdxNow].player[i]; + if (data[i] == 0xFFFFFFFF) { + if (!(window_ptr->player_disable & (1 << i))) { + data[i] = HuPadDStkRep[i] | HuPadBtnDown[i]; } else { - arg1[var_r31] = 0; + data[i] = 0; } } } @@ -1517,262 +1526,268 @@ void HuWinComKeyReset(void) { comKeyIdx = comKeyIdxNow = 0; } -void HuWinMesMaxSizeGet(s16 arg0, f32* arg1, ...) { - s16 var_r31; - u32 temp_r29; +void HuWinMesMaxSizeGet(s16 mess_num, f32* size, ...) { + s16 i; + u32 mess; va_list list; winInsertF = 0; - va_start(list, arg1); + va_start(list, size); winMaxWidth = winMaxHeight = 0; - for (var_r31 = 0; var_r31 < arg0; var_r31++) { - temp_r29 = va_arg(list, u32); - GetMesMaxSizeSub(temp_r29); + for(i=0; i 0x80000000) { - var_r23 = 0; - var_r31 = (u8*) arg0; + mess_start = NULL; + cr_flag = 0; + if (mess > 0x80000000) { + from_messdata = 0; + mess_data = (u8 *)mess; } else { - var_r23 = 1; - var_r31 = var_r24 = MessData_MesPtrGet(messDataPtr, arg0); + from_messdata = 1; + mess_data = mess_start = MessData_MesPtrGet(messDataPtr, mess); } - var_r28 = 0x1A; - var_r30 = 0; - while (*var_r31 != 0) { - var_r27 = 0; - var_r29 = fontWidthP[*var_r31] + 1; - switch (*var_r31) { - case 0x10: - case 0x20: + line_h = 26; + line_w = 0; + while (*mess_data != 0) { + char_h = 0; + char_w = fontWidthP[*mess_data] + 1; + switch (*mess_data) { + case 16: + case 32: break; - case 0x1E: - var_r31++; - var_r29 = 0; + case 30: + mess_data++; + char_w = 0; break; - case 0xA: - if (var_r26 != 0) { + case 10: + if (cr_flag != 0) { if (cancelCRF == 0) { - if (winMaxWidth < var_r30) { - winMaxWidth = var_r30; + if (winMaxWidth < line_w) { + winMaxWidth = line_w; } - var_r30 = var_r29 = 0; - if (var_r31[1] != 0) { - var_r27 = 0x1A; + line_w = char_w = 0; + if (mess_data[1] != 0) { + char_h = 26; } } else { - var_r29 = fontWidthP[0x10] + 1; + char_w = fontWidthP[16] + 1; } } break; - case 0xFF: - var_r30 += var_r29; + case 255: + line_w += char_w; /* fallthrough */ - case 0xB: - var_r26 = 0; + case 11: + cr_flag = 0; if (winInsertF == 0) { - if (winMaxWidth < var_r30) { - winMaxWidth = var_r30; + if (winMaxWidth < line_w) { + winMaxWidth = line_w; } - if (winMaxHeight < var_r28) { - winMaxHeight = var_r28; + if (winMaxHeight < line_h) { + winMaxHeight = line_h; } - var_r28 = 0x1A; - var_r27 = 0; - var_r30 = var_r29 = 0; + line_h = 26; + char_h = 0; + line_w = char_w = 0; } break; - case 0x1C: - var_r31++; + case 28: + mess_data++; /* fallthrough */ - case 0xF: - case 0x1D: - var_r29 = 0; + case 15: + case 29: + char_w = 0; break; - case 0xC: - var_r29 = winTabSize * ((var_r30 + winTabSize) / winTabSize) - var_r30; + case 12: + char_w = winTabSize * ((line_w + winTabSize) / winTabSize) - line_w; break; - case 0xE: - var_r31++; - var_r29 = spcFontTbl[*var_r31 - 1].w + 1; + case 14: + mess_data++; + char_w = spcFontTbl[*mess_data - 1].w + 1; break; - case 0x1F: - var_r31++; - var_r29 = mesWInsert[*var_r31 - 1]; + case 31: + mess_data++; + char_w = mesWInsert[*mess_data - 1]; break; } - if ((*var_r31 != 0xFF && *var_r31 >= 0x20) || *var_r31 == 0x10) { - var_r26 = 1; + if ((*mess_data != 255 && *mess_data >= 32) || *mess_data == 16) { + cr_flag = 1; } - var_r30 += var_r29; - var_r28 += var_r27; - var_r31++; + line_w += char_w; + line_h += char_h; + mess_data++; } - if (winMaxWidth < var_r30) { - winMaxWidth = var_r30; + if (winMaxWidth < line_w) { + winMaxWidth = line_w; } - if (winMaxHeight < var_r28) { - winMaxHeight = var_r28; + if (winMaxHeight < line_h) { + winMaxHeight = line_h; } } -static s32 GetMesMaxSizeSub2(SomeWindowStruct* arg0, u8* arg1) { +static s32 GetMesMaxSizeSub2(WindowData *window, u8 *mess_data) { s32 sp8; - u8 var_r26; - s16 var_r28; - s16 var_r29; - s16 var_r30; - s32 var_r27; - s16 var_r25; - u8* var_r31; + u8 mess_finish; + s16 mess_h; + s16 char_w; + s16 mess_w; + s32 mess_end; + s16 char_h; + u8 *mess; sp8 = 0; - var_r27 = 0; - var_r31 = arg1; - var_r28 = 0x1A; - var_r30 = 0; - var_r26 = 0; - while (*var_r31 != 0 && var_r26 == 0) { - var_r25 = 0; - var_r29 = fontWidthP[*var_r31] + 1; - switch (*var_r31) { - case 0x10: - case 0x20: + mess_end = 0; + mess = mess_data; + mess_h = 0x1A; + mess_w = 0; + mess_finish = 0; + while (*mess != 0 && mess_finish == 0) { + char_h = 0; + char_w = fontWidthP[*mess] + 1; + switch (*mess) { + case 16: + case 32: break; - case 0xA: - if (var_r27 != 0 && !(arg0->attr & 0x100)) { - var_r29 = 0; - var_r26 = 1; + + case 10: + if (mess_end != 0 && !(window->attr & 0x100)) { + char_w = 0; + mess_finish = 1; } break; - case 0xFF: - var_r30 += var_r29; + + case 255: + mess_w += char_w; /* fallthrough */ - case 0xB: - var_r27 = 0; - var_r28 = 0x1A; - var_r25 = 0; - var_r30 = var_r29 = 0; + case 11: + mess_end = 0; + mess_h = 0x1A; + char_h = 0; + mess_w = char_w = 0; break; - case 0x1C: - case 0x1E: - var_r31++; + + case 28: + case 30: + mess++; /* fallthrough */ - case 0xF: - case 0x1D: - var_r29 = 0; + case 15: + case 29: + char_w = 0; break; - case 0xC: - var_r29 = winTabSize * ((var_r30 + winTabSize) / winTabSize) - var_r30; + + case 12: + char_w = winTabSize * ((mess_w + winTabSize) / winTabSize) - mess_w; break; - case 0xE: - var_r31++; - var_r29 = spcFontTbl[*var_r31 - 1].w + 1; + + case 14: + mess++; + char_w = spcFontTbl[*mess - 1].w + 1; break; - case 0x1F: - var_r31++; + + case 31: + mess++; break; } - if ((*var_r31 != 0xFF && *var_r31 >= 0x20) || *var_r31 == 0x10) { - var_r27 = 1; + if ((*mess != 0xFF && *mess >= 0x20) || *mess == 0x10) { + mess_end = 1; } - var_r30 += var_r29; - var_r28 += var_r25; - var_r31++; + mess_w += char_w; + mess_h += char_h; + mess++; } - return var_r30; + return mess_w; } -s32 HuWinKeyWaitNumGet(u32 arg0) { - s32 var_r30; - u8* var_r31; +s32 HuWinKeyWaitNumGet(u32 mess) { + s32 wait_num; + u8 *mess_data; - if (arg0 > 0x80000000) { - var_r31 = (u8*) arg0; + if (mess > 0x80000000) { + mess_data = (u8 *)mess; } else { - var_r31 = MessData_MesPtrGet(messDataPtr, arg0); + mess_data = MessData_MesPtrGet(messDataPtr, mess); } - for (var_r30 = 0; *var_r31 != 0; var_r31++) { - if (*var_r31 == 0xFF) { - var_r30++; + for (wait_num = 0; *mess_data != 0; mess_data++) { + if (*mess_data == 0xFF) { + wait_num++; } } - return var_r30; + return wait_num; } -void HuWinPushKeySet(s16 arg0, s16 arg1) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +void HuWinPushKeySet(s16 window, s16 push_key) { + WindowData *window_ptr = &winData[window]; - temp_r31->push_key = arg1; + window_ptr->push_key = push_key; } -void HuWinDisablePlayerSet(s16 arg0, u8 arg1) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +void HuWinDisablePlayerSet(s16 window, u8 player) { + WindowData *window_ptr = &winData[window]; - temp_r31->player_disable |= arg1; + window_ptr->player_disable |= player; } -void HuWinDisablePlayerReset(s16 arg0, s32 arg1) { - SomeWindowStruct* temp_r31 = &winData[arg0]; +void HuWinDisablePlayerReset(s16 window, s32 player) { + WindowData *window_ptr = &winData[window]; - temp_r31->player_disable &= ~arg1; + window_ptr->player_disable &= ~player; } -void HuWinExCreate(f32 arg0, f32 arg1, s16 arg2, s16 arg3, s16 arg4) { - HuWinExCreateStyled(arg0, arg1, arg2, arg3, arg4, 0); +void HuWinExCreate(f32 x, f32 y, s16 w, s16 h, s16 arg4) { + HuWinExCreateStyled(x, y, w, h, arg4, 0); } static s32 winPortraitTbl[] = { @@ -1797,117 +1812,114 @@ static s32 winPortraitTbl[] = { MAKE_DATA_NUM(DATADIR_WIN, 14) }; -static inline void HuWinExCreateStyledInlineFunc(s16 arg0, s16 arg1, f32 arg2, f32 arg3) { - s16 var_1; - AnimData* var_2; - SomeWindowStruct* var_3; - void* var_4; +static void HuWinExCreatePortrait(s16 window, s16 portrait, f32 x, f32 y) { + s16 sprite; + AnimData *anim; + WindowData *window_ptr; + void *data; - var_4 = HuAR_ARAMtoMRAMFileRead(winPortraitTbl[arg1], MEMORY_DEFAULT_NUM, 2); - var_2 = HuSprAnimRead(var_4); - var_3 = &winData[arg0]; - var_1 = HuSprCreate(var_2, var_3->prio - 1, 0); - HuWinSprSet(arg0, var_1, arg2, arg3); + data = HuAR_ARAMtoMRAMFileRead(winPortraitTbl[portrait], MEMORY_DEFAULT_NUM, 2); + anim = HuSprAnimRead(data); + window_ptr = &winData[window]; + sprite = HuSprCreate(anim, window_ptr->prio - 1, 0); + HuWinSprSet(window, sprite, x, y); } -s16 HuWinExCreateStyled(f32 arg0, f32 arg1, s16 arg2, s16 arg3, s16 arg4, s16 arg5) { - SomeWindowStruct* temp_r24; - s16 temp_r28; +s16 HuWinExCreateStyled(f32 x, f32 y, s16 w, s16 h, s16 portrait, s16 frame) { + WindowData *window_ptr; + s16 window; - if (arg4 >= 0) { - arg3 = (arg3 < 0x54) ? 0x54 : arg3; + if (portrait >= 0) { + h = (h < 0x54) ? 0x54 : h; } - temp_r28 = HuWinCreate(arg0, arg1, arg2, arg3, arg5); - temp_r24 = &winData[temp_r28]; - if (arg5 == 1) { - temp_r24->mess_shadow_color = 9; + window = HuWinCreate(x, y, w, h, frame); + window_ptr = &winData[window]; + if (frame == 1) { + window_ptr->mess_shadow_color = 9; } - if (arg4 >= 0) { - HuWinExCreateStyledInlineFunc(temp_r28, arg4, 48.0f, 48.0f); + if (portrait >= 0) { + HuWinExCreatePortrait(window, portrait, 48.0f, 48.0f); } - HuWinDispOff(temp_r28); - return temp_r28; + HuWinDispOff(window); + return window; } -void HuWinExAnimIn(s16 arg0) { - SomeWindowStruct* temp_r31 = &winData[arg0]; - s16 var_r30; - s16 temp_r22; +void HuWinExAnimIn(s16 window) { + WindowData *window_ptr = &winData[window]; + s16 i; - _HuWinHomeClear(temp_r31); - if (temp_r31->sprite_id[2] == -1) { - HuSprScaleSet(temp_r31->group, 0, 1.0f, 0.0f); - HuWinDispOn(arg0); - for (var_r30 = 0; var_r30 <= 10; var_r30++) { - HuSprScaleSet(temp_r31->group, 0, 1.0f, 1.0 - 1.1 * cos(M_PI * (9.0f * var_r30) / 180.0)); + _HuWinHomeClear(window_ptr); + if (window_ptr->sprite_id[2] == -1) { + HuSprScaleSet(window_ptr->group, 0, 1.0f, 0.0f); + HuWinDispOn(window); + for (i=0; i<=10; i++) { + HuSprScaleSet(window_ptr->group, 0, 1.0f, 1.0 - 1.1 * cos(M_PI * (9.0f * i) / 180.0)); HuPrcVSleep(); } - HuSprScaleSet(temp_r31->group, 0, 1.0f, 1.0f); + HuSprScaleSet(window_ptr->group, 0, 1.0f, 1.0f); } else { - HuSprScaleSet(temp_r31->group, 0, 1.0f, 0.0f); - HuSprScaleSet(temp_r31->group, 2, 1.0f, 0.0f); - HuWinDispOn(arg0); - for (var_r30 = 0; var_r30 <= 20; var_r30++) { - if (var_r30 <= 10) { - HuSprScaleSet(temp_r31->group, 0, 1.0f, 1.1 * (1.0 - cos(M_PI * (9.0f * var_r30) / 180.0))); + HuSprScaleSet(window_ptr->group, 0, 1.0f, 0.0f); + HuSprScaleSet(window_ptr->group, 2, 1.0f, 0.0f); + HuWinDispOn(window); + for (i=0; i<=20; i++) { + if (i <= 10) { + HuSprScaleSet(window_ptr->group, 0, 1.0f, 1.1 * (1.0 - cos(M_PI * (9.0f * i) / 180.0))); } else { - HuSprScaleSet(temp_r31->group, 0, 1.0f, 1.0f); + HuSprScaleSet(window_ptr->group, 0, 1.0f, 1.0f); } - if (var_r30 > 10) { - temp_r22 = var_r30 - 10; - HuSprScaleSet(temp_r31->group, 2, 1.0f, 1.0 - 1.1 * cos(M_PI * (9.0f * temp_r22) / 180.0)); + if (i > 10) { + s16 time = i - 10; + HuSprScaleSet(window_ptr->group, 2, 1.0f, 1.0 - 1.1 * cos(M_PI * (9.0f * time) / 180.0)); } HuPrcVSleep(); } - HuSprScaleSet(temp_r31->group, 2, 1.0f, 1.0f); + HuSprScaleSet(window_ptr->group, 2, 1.0f, 1.0f); } } -void HuWinExAnimOut(s16 arg0) { - SomeWindowStruct* temp_r31 = &winData[arg0]; - s16 var_r24; - s16 var_r30; - s16 temp_r22; +void HuWinExAnimOut(s16 window) { + WindowData *window_ptr = &winData[window]; + s16 i; - _HuWinHomeClear(temp_r31); - if (temp_r31->sprite_id[2] == -1) { - for (var_r30 = 0; var_r30 <= 10; var_r30++) { - HuSprScaleSet(temp_r31->group, 0, 1.0f, cos(M_PI * (9.0f * var_r30) / 180.0)); + _HuWinHomeClear(window_ptr); + if (window_ptr->sprite_id[2] == -1) { + for (i=0; i<=10; i++) { + HuSprScaleSet(window_ptr->group, 0, 1.0f, cos(M_PI * (9.0f * i) / 180.0)); HuPrcVSleep(); } - HuWinDispOff(arg0); + HuWinDispOff(window); } else { - for (var_r30 = 0; var_r30 <= 15; var_r30++) { - if (var_r30 <= 10) { - HuSprScaleSet(temp_r31->group, 2, 1.0f, cos(M_PI * (9.0f * var_r30) / 180.0)); + for (i=0; i<=15; i++) { + if (i <= 10) { + HuSprScaleSet(window_ptr->group, 2, 1.0f, cos(M_PI * (9.0f * i) / 180.0)); } - if (var_r30 > 5) { - temp_r22 = var_r30 - 5; - HuSprScaleSet(temp_r31->group, 0, 1.0f, cos(M_PI * (9.0f * temp_r22) / 180.0)); + if (i > 5) { + s16 time = i - 5; + HuSprScaleSet(window_ptr->group, 0, 1.0f, cos(M_PI * (9.0f * time) / 180.0)); } HuPrcVSleep(); } - HuWinDispOff(arg0); + HuWinDispOff(window); } } -void HuWinExCleanup(s16 arg0) { - HuWinKill(arg0); +void HuWinExCleanup(s16 window) { + HuWinKill(window); } -void HuWinExAnimPopIn(s16 arg0, s16 arg1) { - SomeWindowStruct* temp_r28 = &winData[arg0]; - s16 var_r30; +void HuWinExAnimPopIn(s16 window, s16 portrait) { + WindowData *window_ptr = &winData[window]; + s16 i; - for (var_r30 = 0; var_r30 <= 10; var_r30++) { - HuSprScaleSet(temp_r28->group, 2, 1.0f, cos(M_PI * (9.0f * var_r30) / 180.0)); + for (i=0; i<=10; i++) { + HuSprScaleSet(window_ptr->group, 2, 1.0f, cos(M_PI * (9.0f * i) / 180.0)); HuPrcVSleep(); } - HuWinSprKill(arg0, 2); - HuWinExCreateStyledInlineFunc(arg0, arg1, 48.0f, 48.0f); - for (var_r30 = 0; var_r30 <= 10; var_r30++) { - HuSprScaleSet(temp_r28->group, 2, 1.0f, sin(M_PI * (9.0f * var_r30) / 180.0)); + HuWinSprKill(window, 2); + HuWinExCreatePortrait(window, portrait, 48.0f, 48.0f); + for (i=0; i<=10; i++) { + HuSprScaleSet(window_ptr->group, 2, 1.0f, sin(M_PI * (9.0f * i) / 180.0)); HuPrcVSleep(); } - HuSprScaleSet(temp_r28->group, 2, 1.0f, 1.0f); + HuSprScaleSet(window_ptr->group, 2, 1.0f, 1.0f); } From 3a297f36b0f20722f54429b5fbbc0931f0887c25 Mon Sep 17 00:00:00 2001 From: gamemasterplc Date: Fri, 22 Dec 2023 17:37:22 -0600 Subject: [PATCH 3/4] Fix function prototypes --- include/game/window.h | 121 +++++++++++++++++++++--------------------- src/game/window.c | 102 +++++++++++++++++------------------ 2 files changed, 112 insertions(+), 111 deletions(-) diff --git a/include/game/window.h b/include/game/window.h index 9be6c154..8cb963f3 100644 --- a/include/game/window.h +++ b/include/game/window.h @@ -44,11 +44,11 @@ typedef struct { /* 0x066 */ s16 spacing_y; /* 0x068 */ s16 w; /* 0x06A */ s16 h; - /* 0x06C */ f32 pos_x; - /* 0x070 */ f32 pos_y; - /* 0x074 */ f32 scale_x; - /* 0x078 */ f32 scale_y; - /* 0x07C */ f32 rot; + /* 0x06C */ float pos_x; + /* 0x070 */ float pos_y; + /* 0x074 */ float scale_x; + /* 0x078 */ float scale_y; + /* 0x07C */ float z_rot; /* 0x080 */ s16 num_chars; /* 0x082 */ s16 max_chars; /* 0x084 */ WinChar *char_data; @@ -74,62 +74,63 @@ typedef struct { } WindowData; // Size 0x180 void HuWindowInit(void); -void HuWinInit(s32 arg0); -s16 HuWinCreate(f32 x, f32 y, s16 w, s16 h, s16 frame); -void HuWinKill(s16 arg0); +void HuWinInit(s32 mess_data_no); +s16 HuWinCreate(float x, float y, s16 w, s16 h, s16 frame); +void HuWinKill(s16 window); void HuWinAllKill(void); -void HuWinHomeClear(s16 arg0); -void HuWinKeyWaitEntry(s16 arg0); -u32 HuWinActivePadGet(WindowData* arg0); -u32 HuWinActiveKeyGetX(WindowData* arg0); -void HuWinPosSet(s16 arg0, f32 arg1, f32 arg2); -void HuWinScaleSet(s16 arg0, f32 arg1, f32 arg2); -void HuWinZRotSet(s16 arg0, f32 arg1); -void HuWinCenterPosSet(s16 arg0, f32 arg1, f32 arg2); -void HuWinDrawNoSet(s16 arg0, s16 arg1); -void HuWinScissorSet(s16 arg0, s16 arg1, s16 arg2, s16 arg3, s16 arg4); -void HuWinPriSet(s16 arg0, s16 arg1); -void HuWinAttrSet(s16 arg0, s32 arg1); -void HuWinAttrReset(s16 arg0, u32 arg1); -u8 HuWinStatGet(s16 arg0); -void HuWinMesColSet(s16 arg0, u8 arg1); -void HuWinMesPalSet(s16 arg0, u8 arg1, u8 arg2, u8 arg3, u8 arg4); -void HuWinBGTPLvlSet(s16 arg0, f32 arg1); -void HuWinBGColSet(s16 arg0, GXColor *arg1); -void HuWinMesSpeedSet(s16 arg0, s16 arg1); -void HuWinMesRead(s32 arg0); -void HuWinMesSet(s16 arg0, u32 arg1); -void HuWinInsertMesSet(s16 arg0, u32 arg1, s16 arg2); -s16 HuWinChoiceGet(s16 arg0, s16 arg1); -s16 HuWinChoiceNumGet(s16 arg0); -void HuWinChoiceDisable(s16 arg0, s16 arg1); -s16 HuWinChoiceNowGet(s16 arg0); -void HuWinMesWait(s16 arg0); -void HuWinAnimSet(s16 arg0, AnimData* arg1, s16 arg2, f32 arg3, f32 arg4); -s16 HuWinSprSet(s16 arg0, s16 arg1, f32 arg2, f32 arg3); -void HuWinSprPosSet(s16 arg0, s16 arg1, f32 arg2, f32 arg3); -void HuWinSprPriSet(s16 arg0, s16 arg1, s16 arg2); -s16 HuWinSprIDGet(s16 arg0, s16 arg1); -void HuWinSprKill(s16 arg0, s16 arg1); -void HuWinDispOff(s16 arg0); -void HuWinDispOn(s16 arg0); -void HuWinComKeyWait(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s16 arg4); -void HuWinComKeySet(s32 arg0, s32 arg1, s32 arg2, s32 arg3); -void _HuWinComKeySet(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s16 arg4); -void HuWinComKeyGet(s16 arg0, u32* arg1); +void HuWinHomeClear(s16 window); +void HuWinKeyWaitEntry(s16 window); +u32 HuWinActivePadGet(WindowData *window); +u32 HuWinActiveKeyGetX(WindowData *window); +void HuWinPosSet(s16 window, float x, float y); +void HuWinScaleSet(s16 window, float x, float y); +void HuWinZRotSet(s16 window, float z_rot); +void HuWinCenterPosSet(s16 window, float x, float y); +void HuWinDrawNoSet(s16 window, s16 draw_no); +void HuWinScissorSet(s16 window, s16 x, s16 y, s16 w, s16 h); +void HuWinPriSet(s16 window, s16 prio); +void HuWinAttrSet(s16 window, u32 attr); +void HuWinAttrReset(s16 window, u32 attr); +u8 HuWinStatGet(s16 window); +void HuWinMesColSet(s16 window, u8 color); +void HuWinMesPalSet(s16 window, u8 index, u8 r, u8 g, u8 b); +void HuWinBGTPLvlSet(s16 window, float tp_level); +void HuWinBGColSet(s16 window, GXColor *bg_color); +void HuWinMesSpeedSet(s16 window, s16 speed); +void HuWinMesRead(s32 mess_data_no); +void HuWinMesSet(s16 window, u32 mess); +void HuWinInsertMesSet(s16 window, u32 mess, s16 index); +s16 HuWinChoiceGet(s16 window, s16 start_choice); +s16 HuWinChoiceNumGet(s16 window); +void HuWinChoiceDisable(s16 window, s16 choice); +s16 HuWinChoiceNowGet(s16 window); +void HuWinMesWait(s16 window); +void HuWinAnimSet(s16 window, AnimData *anim, s16 bank, float x, float y); +s16 HuWinSprSet(s16 window, s16 sprite, float x, float y); +void HuWinSprPosSet(s16 window, s16 index, float x, float y); +void HuWinSprPriSet(s16 window, s16 index, s16 prio); +s16 HuWinSprIDGet(s16 window, s16 index); +void HuWinSprKill(s16 window, s16 index); +void HuWinDispOff(s16 window); +void HuWinDispOn(s16 window); +void HuWinComKeyWait(s32 player_1, s32 player_2, s32 player_3, s32 player_4, s16 delay); +void HuWinComKeySet(s32 player_1, s32 player_2, s32 player_3, s32 player_4); +void _HuWinComKeySet(s32 player_1, s32 player_2, s32 player_3, s32 player_4, s16 delay); +void HuWinComKeyGet(s16 window, u32 *data); void HuWinComKeyReset(void); -void HuWinInsertMesSizeGet(s32 arg0, s16 arg1); -void HuWinMesSizeCancelCRSet(s32 arg0); -void HuWinMesMaxSizeBetGet(f32* arg0, u32 arg1, u32 arg2); -s32 HuWinKeyWaitNumGet(u32 arg0); -void HuWinPushKeySet(s16 arg0, s16 arg1); -void HuWinDisablePlayerSet(s16 arg0, u8 arg1); -void HuWinDisablePlayerReset(s16 arg0, s32 arg1); -void HuWinExCreate(f32 arg0, f32 arg1, s16 arg2, s16 arg3, s16 arg4); -s16 HuWinExCreateStyled(f32 arg0, f32 arg1, s16 arg2, s16 arg3, s16 arg4, s16 arg5); -void HuWinExAnimIn(s16 arg0); -void HuWinExAnimOut(s16 arg0); -void HuWinExCleanup(s16 arg0); -void HuWinExAnimPopIn(s16 arg0, s16 arg1); +void HuWinMesMaxSizeGet(s16 mess_num, float *size, ...); +void HuWinInsertMesSizeGet(s32 mess, s16 index); +void HuWinMesSizeCancelCRSet(s32 cancel_cr); +void HuWinMesMaxSizeBetGet(float *size, u32 start, u32 end); +s32 HuWinKeyWaitNumGet(u32 mess); +void HuWinPushKeySet(s16 window, s16 push_key); +void HuWinDisablePlayerSet(s16 window, u8 player); +void HuWinDisablePlayerReset(s16 window, u8 player); +s16 HuWinExCreate(float x, float y, s16 w, s16 h, s16 portrait); +s16 HuWinExCreateStyled(float x, float y, s16 w, s16 h, s16 portrait, s16 frame); +void HuWinExAnimIn(s16 window); +void HuWinExAnimOut(s16 window); +void HuWinExCleanup(s16 window); +void HuWinExAnimPopIn(s16 window, s16 portrait); #endif diff --git a/src/game/window.c b/src/game/window.c index 815ce8f5..3ce37ffc 100644 --- a/src/game/window.c +++ b/src/game/window.c @@ -47,7 +47,7 @@ void HuAR_ARAMtoMRAM(void*); void HuDataDirClose(s32); void* HuDataReadNum(s32, s32); -void mtxTransCat(Mtx, f32, f32, f32); +void mtxTransCat(Mtx, float, float, float); void* MessData_MesPtrGet(void*, u32); extern u16 HuPadBtn[4]; @@ -259,7 +259,7 @@ void HuWinInit(s32 mess_data_no) { } } -s16 HuWinCreate(f32 x, f32 y, s16 w, s16 h, s16 frame) { +s16 HuWinCreate(float x, float y, s16 w, s16 h, s16 frame) { AnimData *bg_anim; WindowData *window; SpriteData *sprite_ptr; @@ -362,19 +362,19 @@ s16 HuWinCreate(f32 x, f32 y, s16 w, s16 h, s16 frame) { return window_id; } -void HuWinKill(s16 window_id) { - WindowData *window = &winData[window_id]; +void HuWinKill(s16 window) { + WindowData *window_ptr = &winData[window]; s16 i; - if (window->group != -1) { - HuMemDirectFree(window->char_data); + if (window_ptr->group != -1) { + HuMemDirectFree(window_ptr->char_data); for (i = 2; i < 30; i++) { - if (window->sprite_id[i] != -1) { - HuSprGrpMemberKill(window->group, i); + if (window_ptr->sprite_id[i] != -1) { + HuSprGrpMemberKill(window_ptr->group, i); } } - HuSprGrpKill(window->group); - window->group = -1; + HuSprGrpKill(window_ptr->group); + window_ptr->group = -1; } } @@ -420,14 +420,14 @@ void HuWinAllKill(void) { static void MesDispFunc(SpriteData *sprite) { WindowData *window = &winData[sprite->work[0]]; SpriteGroupData *group; - f32 uv_maxx; - f32 uv_maxy; - f32 uv_minx; - f32 uv_miny; - f32 char_w; - f32 char_x; - f32 char_y; - f32 char_uv_h; + float uv_maxx; + float uv_maxy; + float uv_minx; + float uv_miny; + float char_w; + float char_x; + float char_y; + float char_uv_h; s16 i; u16 alpha; s16 color; @@ -490,16 +490,16 @@ static void MesDispFunc(SpriteData *sprite) { } GXPosition3f32(char_x + 1.0f, char_y, 0.0f); GXColor4u8(window->mess_pal[color][0], window->mess_pal[color][1], window->mess_pal[color][2], alpha); - GXTexCoord2f32(uv_minx, uv_miny); + GXPosition2f32(uv_minx, uv_miny); GXPosition3f32(char_x + char_w, char_y, 0.0f); GXColor4u8(window->mess_pal[color][0], window->mess_pal[color][1], window->mess_pal[color][2], alpha); - GXTexCoord2f32(uv_maxx, uv_miny); + GXPosition2f32(uv_maxx, uv_miny); GXPosition3f32(char_x + char_w, char_y + 24.0f, 0.0f); GXColor4u8(window->mess_pal[color][0], window->mess_pal[color][1], window->mess_pal[color][2], alpha); - GXTexCoord2f32(uv_maxx, uv_maxy); + GXPosition2f32(uv_maxx, uv_maxy); GXPosition3f32(char_x + 1.0f, char_y + 24.0f, 0.0f); GXColor4u8(window->mess_pal[color][0], window->mess_pal[color][1], window->mess_pal[color][2], alpha); - GXTexCoord2f32(uv_minx, uv_maxy); + GXPosition2f32(uv_minx, uv_maxy); } GXEnd(); mesCharCnt++; @@ -934,8 +934,8 @@ static void HuWinSpcFontClear(WindowData* window) { static void HuWinChoice(WindowData *window) { WinChoice *choice; - f32 choice_dist; - f32 min_choice_dist_x; + float choice_dist; + float min_choice_dist_x; s16 choice_dist_y; s16 key; s16 choice_curr_x; @@ -1145,7 +1145,7 @@ u32 HuWinActiveKeyGetX(WindowData *window) { return button; } -void HuWinPosSet(s16 window, f32 x, f32 y) { +void HuWinPosSet(s16 window, float x, float y) { WindowData *window_ptr = &winData[window]; window_ptr->pos_x = x; @@ -1153,7 +1153,7 @@ void HuWinPosSet(s16 window, f32 x, f32 y) { HuSprGrpPosSet(window_ptr->group, x, y); } -void HuWinScaleSet(s16 window, f32 x, f32 y) { +void HuWinScaleSet(s16 window, float x, float y) { WindowData *window_ptr = &winData[window]; window_ptr->scale_x = x; @@ -1161,14 +1161,14 @@ void HuWinScaleSet(s16 window, f32 x, f32 y) { HuSprGrpScaleSet(window_ptr->group, x, y); } -void HuWinZRotSet(s16 window, f32 rot) { +void HuWinZRotSet(s16 window, float z_rot) { WindowData *window_ptr = &winData[window]; - window_ptr->rot = rot; - HuSprGrpZRotSet(window_ptr->group, rot); + window_ptr->z_rot = z_rot; + HuSprGrpZRotSet(window_ptr->group, z_rot); } -void HuWinCenterPosSet(s16 window, f32 x, f32 y) { +void HuWinCenterPosSet(s16 window, float x, float y) { WindowData *window_ptr = &winData[window]; HuSprGrpCenterSet(window_ptr->group, window_ptr->w / 2.0f - x, window_ptr->h / 2.0f - y); @@ -1200,7 +1200,7 @@ void HuWinPriSet(s16 window, s16 prio) { window_ptr->prio = prio; } -void HuWinAttrSet(s16 window, s32 attr) { +void HuWinAttrSet(s16 window, u32 attr) { WindowData *window_ptr = &winData[window]; window_ptr->attr |= attr; @@ -1233,7 +1233,7 @@ void HuWinMesPalSet(s16 window, u8 index, u8 r, u8 g, u8 b) { window_ptr->mess_pal[index][2] = b; } -void HuWinBGTPLvlSet(s16 window, f32 tp_level) { +void HuWinBGTPLvlSet(s16 window, float tp_level) { WindowData *window_ptr = &winData[window]; HuSprTPLvlSet(window_ptr->group, 0, tp_level); @@ -1372,7 +1372,7 @@ void HuWinMesWait(s16 window) { } } -void HuWinAnimSet(s16 window, AnimData *anim, s16 bank, f32 x, f32 y) { +void HuWinAnimSet(s16 window, AnimData *anim, s16 bank, float x, float y) { WindowData *window_ptr = &winData[window]; s16 sprite; @@ -1380,7 +1380,7 @@ void HuWinAnimSet(s16 window, AnimData *anim, s16 bank, f32 x, f32 y) { HuWinSprSet(window, sprite, x, y); } -s16 HuWinSprSet(s16 window, s16 sprite, f32 x, f32 y) { +s16 HuWinSprSet(s16 window, s16 sprite, float x, float y) { WindowData *window_ptr = &winData[window]; SpriteGroupData *group = &HuSprGrpData[window_ptr->group]; s16 i; @@ -1396,18 +1396,18 @@ s16 HuWinSprSet(s16 window, s16 sprite, f32 x, f32 y) { return i; } -void HuWinSprPosSet(s16 window, s16 sprite, f32 x, f32 y) { +void HuWinSprPosSet(s16 window, s16 index, float x, float y) { WindowData *window_ptr = &winData[window]; SpriteGroupData *group = &HuSprGrpData[window_ptr->group]; - HuSprPosSet(window_ptr->group, sprite, x - group->center_x, y - group->center_y); + HuSprPosSet(window_ptr->group, index, x - group->center_x, y - group->center_y); } -void HuWinSprPriSet(s16 window, s16 sprite, s16 prio) { +void HuWinSprPriSet(s16 window, s16 index, s16 prio) { WindowData *window_ptr = &winData[window]; SpriteGroupData *group = &HuSprGrpData[window_ptr->group]; - HuSprPriSet(window_ptr->group, sprite, prio); + HuSprPriSet(window_ptr->group, index, prio); } s16 HuWinSprIDGet(s16 window, s16 index) { @@ -1416,11 +1416,11 @@ s16 HuWinSprIDGet(s16 window, s16 index) { return window_ptr->sprite_id[index]; } -void HuWinSprKill(s16 window, s16 sprite) { +void HuWinSprKill(s16 window, s16 index) { WindowData *window_ptr = &winData[window]; - HuSprGrpMemberKill(window_ptr->group, sprite); - window_ptr->sprite_id[sprite] = -1; + HuSprGrpMemberKill(window_ptr->group, index); + window_ptr->sprite_id[index] = -1; } void HuWinDispOff(s16 window) { @@ -1526,7 +1526,7 @@ void HuWinComKeyReset(void) { comKeyIdx = comKeyIdxNow = 0; } -void HuWinMesMaxSizeGet(s16 mess_num, f32* size, ...) { +void HuWinMesMaxSizeGet(s16 mess_num, float *size, ...) { s16 i; u32 mess; va_list list; @@ -1559,7 +1559,7 @@ void HuWinMesSizeCancelCRSet(s32 cancel_cr) { cancelCRF = cancel_cr; } -void HuWinMesMaxSizeBetGet(f32 *size, u32 start, u32 end) { +void HuWinMesMaxSizeBetGet(float *size, u32 start, u32 end) { u32 i; if (end < start) { @@ -1780,14 +1780,10 @@ void HuWinDisablePlayerSet(s16 window, u8 player) { window_ptr->player_disable |= player; } -void HuWinDisablePlayerReset(s16 window, s32 player) { +void HuWinDisablePlayerReset(s16 window, u8 player) { WindowData *window_ptr = &winData[window]; - window_ptr->player_disable &= ~player; -} - -void HuWinExCreate(f32 x, f32 y, s16 w, s16 h, s16 arg4) { - HuWinExCreateStyled(x, y, w, h, arg4, 0); + window_ptr->player_disable &= ~(int)player; } static s32 winPortraitTbl[] = { @@ -1812,7 +1808,11 @@ static s32 winPortraitTbl[] = { MAKE_DATA_NUM(DATADIR_WIN, 14) }; -static void HuWinExCreatePortrait(s16 window, s16 portrait, f32 x, f32 y) { +s16 HuWinExCreate(float x, float y, s16 w, s16 h, s16 portrait) { + return HuWinExCreateStyled(x, y, w, h, portrait, 0); +} + +static void HuWinExCreatePortrait(s16 window, s16 portrait, float x, float y) { s16 sprite; AnimData *anim; WindowData *window_ptr; @@ -1825,7 +1825,7 @@ static void HuWinExCreatePortrait(s16 window, s16 portrait, f32 x, f32 y) { HuWinSprSet(window, sprite, x, y); } -s16 HuWinExCreateStyled(f32 x, f32 y, s16 w, s16 h, s16 portrait, s16 frame) { +s16 HuWinExCreateStyled(float x, float y, s16 w, s16 h, s16 portrait, s16 frame) { WindowData *window_ptr; s16 window; From d4fa564504d6e706eab8819b1da3b0ce7d35778b Mon Sep 17 00:00:00 2001 From: gamemasterplc Date: Fri, 22 Dec 2023 17:45:58 -0600 Subject: [PATCH 4/4] Add Message ID macros --- include/game/window.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/game/window.h b/include/game/window.h index 8cb963f3..7596f913 100644 --- a/include/game/window.h +++ b/include/game/window.h @@ -4,6 +4,8 @@ #include "game/sprite.h" #include "dolphin.h" +#define MAKE_MESSID(bank, mess) (((bank) << 16)+(mess)) +#define MAKE_MESSID_PTR(ptr) ((u32)(ptr)) typedef struct { /* 0x00 */ u8 color;