diff options
| -rw-r--r-- | include/6B3DC0.h | 10 | ||||
| -rw-r--r-- | include/m_choice_main.h | 261 | ||||
| -rw-r--r-- | include/m_msg_main.h | 39 | ||||
| -rw-r--r-- | linker_scripts/jp/symbol_addrs_code.txt | 218 | ||||
| -rw-r--r-- | src/code/m_choice_main.c | 1038 | ||||
| -rw-r--r-- | yamls/jp/code.yaml | 12 |
6 files changed, 1358 insertions, 220 deletions
diff --git a/include/6B3DC0.h b/include/6B3DC0.h index d191522..1289c78 100644 --- a/include/6B3DC0.h +++ b/include/6B3DC0.h @@ -12,7 +12,7 @@ struct Game; // void func_80090178_jp(); // void func_80090188_jp(); // void func_8009028C_jp(); -// void func_800902CC_jp(); +s32 mFont_GetStringWidth(char*, s32, s32); // void func_8009034C_jp(); // void func_800903A8_jp(); // void func_800903CC_jp(); @@ -28,7 +28,7 @@ struct Game; // void func_80090848_jp(); // void func_8009087C_jp(); // void func_80090CC0_jp(); -f32 mFont_SetLineStrings_AndSpace(struct Game*, char*, s32, f32 x, f32 y, s32 , s32 , s32 , s32 , s32, s32, s32, f32, f32, s32); +f32 mFont_SetLineStrings_AndSpace(struct Game*, char*, s32, f32 x, f32 y, s32, s32, s32, s32, s32, s32, s32, f32, f32,s32); // void func_80090E98_jp(); void mFont_SetMatrix(struct GraphicsContext* gfxCtx, s32 type); void mFont_UnSetMatrix(struct GraphicsContext* gfxCtx, s32 type); @@ -63,11 +63,11 @@ void func_80091074_jp(struct GraphicsContext* gfxCtx); // void func_80091FCC_jp(); // void func_80092000_jp(); // void func_80092034_jp(); -// void func_800921D0_jp(); +f32 mFont_SetMarkChar(struct Game*, u8, f32, f32, s32, s32, s32, s32, s32, f32, f32, s32); // void func_80092440_jp(); // void func_80092468_jp(); -void func_800924CC_jp(void*,void*,void*); +void func_800924CC_jp(void*, void*, void*); // void func_80092538_jp(); -s32 mFont_UnintToString(char*, u32, s32, s32, s32); +s32 mFont_UnintToString(char*, u32, s32, s32, s32); #endif diff --git a/include/m_choice_main.h b/include/m_choice_main.h index c7998ae..b13a9e8 100644 --- a/include/m_choice_main.h +++ b/include/m_choice_main.h @@ -2,94 +2,179 @@ #define M_CHOICE_MAIN_H #include "ultra64.h" +#include "color.h" -// void func_80065040_jp(); -// void func_80065064_jp(); -// void func_80065158_jp(); -// void func_80065164_jp(); -// void func_80065170_jp(); -// void func_80065198_jp(); -// void func_800651A4_jp(); -// void func_80065278_jp(); -// void func_80065348_jp(); -// void func_800653CC_jp(); -// void func_800653DC_jp(); -// void func_800654FC_jp(); -// void func_80065508_jp(); -// void func_80065518_jp(); -// void func_80065528_jp(); -// void func_80065668_jp(); -// void func_8006568C_jp(); -// void func_800656C8_jp(); -// void func_80065704_jp(); -// void func_80065728_jp(); -// void func_8006574C_jp(); -// void func_80065770_jp(); -// void func_80065794_jp(); -// void func_800657B8_jp(); -// void func_800657DC_jp(); -// void func_80065800_jp(); -// void func_8006584C_jp(); -// void func_8006586C_jp(); -// void func_80065890_jp(); -// void func_800658B4_jp(); -// void func_800658D8_jp(); -// void func_800658FC_jp(); -// void func_80065920_jp(); -// void func_80065944_jp(); -// void func_80065968_jp(); -// void func_8006598C_jp(); -// void func_800659B0_jp(); -// void func_800659D4_jp(); -// void func_800659F8_jp(); -// void func_80065A1C_jp(); -// void func_80065A40_jp(); -// void func_80065A64_jp(); -// void func_80065A88_jp(); -// void func_80065AAC_jp(); -// void func_80065AD0_jp(); -// void func_80065AF4_jp(); -// void func_80065B18_jp(); -// void func_80065B5C_jp(); -// void func_80065B80_jp(); -// void func_80065BA4_jp(); -// void func_80065BF0_jp(); -// void func_80065C10_jp(); -// void func_80065C34_jp(); -// void func_80065C58_jp(); -// void func_80065C7C_jp(); -// void func_80065CA0_jp(); -// void func_80065CF8_jp(); -// void func_80065D90_jp(); -// void func_80065EE8_jp(); -// void func_80065EF8_jp(); -// void func_80065F18_jp(); -// void func_80065F38_jp(); -// void func_80065F58_jp(); -// void func_80065F78_jp(); -// void func_80065F98_jp(); -// void func_80066068_jp(); -// void func_80066094_jp(); -// void func_800660DC_jp(); -// void func_80066130_jp(); -// void func_80066194_jp(); -// void func_800665C0_jp(); -// void func_800665EC_jp(); -// void func_80066634_jp(); -// void func_8006666C_jp(); -// void func_80066740_jp(); -// void func_8006676C_jp(); -// void func_800667B4_jp(); -// void func_8006680C_jp(); -// void func_8006685C_jp(); -// void func_800668A4_jp(); -// void func_800669A4_jp(); -// void func_80066A60_jp(); -// void func_80066A80_jp(); -// void func_80066B18_jp(); -// void func_80066BB0_jp(); -// void func_80066D4C_jp(); -// void func_80066DFC_jp(); -// void func_80066E34_jp(); +struct Game; +struct Actor; + +#define Choice_CHOICE_STRING_LEN 10 + +typedef enum Choice_CHOICE { + Choice_CHOICE0, + Choice_CHOICE1, + Choice_CHOICE2, + Choice_CHOICE3, + Choice_CHOICE_MAX, +} Choice_CHOICE; + +typedef enum Choice_AUTOMOVETYPE { + Choice_AUTOMOVE_STOPPED, + Choice_AUTOMOVE_INCREMENT_WAIT, + Choice_AUTOMOVE_INCREMENT, + Choice_AUTOMOVE_DECREMENT_WAIT, + Choice_AUTOMOVE_DECREMENT, + Choice_AUTOMOVE_MAX +} Choice_AUTOMOVETYPE; + +typedef struct ChoiceData { + /* 0x00 */ char strings[Choice_CHOICE_MAX][Choice_CHOICE_STRING_LEN]; + /* 0x28 */ s32 stringLens[Choice_CHOICE_MAX]; + /* 0x38 */ char determinationString[Choice_CHOICE_STRING_LEN]; + /* 0x44 */ s32 determinationLenght; + /* 0x48 */ s32 choiceNum; + /* 0x4C */ s32 selectedChoiceIdx; +} ChoiceData; // size = 0x50 + +typedef struct Choice { + /* 0x00 */f32 centerX; + /* 0x04 */f32 centerY; + + /* Initial XY position */ + /* 0x08 */ f32 centerXBegin; + /* 0x0C */ f32 centerYBegin; + + /* Target XY position */ + /* 0x10 */ f32 centerXTarget; + /* 0x14 */ f32 centerYTarget; + + /* Text settings */ + /* 0x18 */ Color_RGBA8 textColor; + /* 0x1C */ f32 textScaleX; + /* 0x20 */ f32 textScaleY; + /* 0x24 */ f32 textX; + /* 0x28 */ f32 textY; + + /* Window scaling XY */ + /* 0x2C */ f32 scaleX; + /* 0x30 */ f32 scaleY; + + /* Text related data */ + /* 0x34 */ ChoiceData data; + + /* 0x84 */ s32 selectedChoiceIdx; + /* 0x88 */ Color_RGBA8 selectedChoiceTextColor; + + /* 0x8C */ Color_RGBA8 backgroundColor; + + /* 0x90 */ f32 unk_D4; + /* 0x94 */ f32 unk_D8; + + /* 0x98 */ f32 scale; // total choice window scaling percentage + + /* 0x9C */ s32 mainIdx; + /* 0xA0 */ s32 requestedMainIdx; + + /* 0xA4 */ s32 isWindowVisible; + /* 0xA8 */ s32 isFontVisible; + + /* 0xAC */ s32 choiceAutomoveType; + /* 0xB0 */ f32 choiceAutomoveTimer; + + /* 0xB4 */ f32 timer; + + /* 0xB8 */ u8 noBFlag; // can't press B to select last option + /* 0xB9 */ u8 noCloseFlag; // pressing B won't auto-cancel the choice selection? +} Choice; // size = 0xBC + + +Choice* mChoice_Get_base_window_p(); +void mChoice_init(Choice* choice, struct Game* game); +void mChoice_Change_request_main_index(Choice* choice, s32 idx); +s32 mChoice_check_main_index(Choice* choice); +s32 mChoice_check_main_normal(Choice* choice); +void mChoice_Init_choice_data(Choice* choice); +s32 mChoice_Add_choice_data(Choice* choice, char* str, s32 max_len); +void mChoice_Set_choice_data(Choice* choice, char* str0, s32 str0len, char* str1, s32 str1len, char* str2, s32 str2len, + char* str3, s32 str3len); +s32 mChoice_Get_MaxStringDotWidth(Choice* choice); +s32 mChoice_Get_MaxStringDotHeight(Choice* choice); +void mChoice_Set_DisplayScaleAndDisplayPos(Choice* choice); +s32 mChoice_Get_ChoseNum(Choice* choice); +void mChoice_Clear_ChoseNum(Choice* choice); +void mChoice_check_ct( Choice* choice, struct Game* game); +void mChoice_Get_StringDataAddressAndSize(s32 idx, u32** addr, u32* size); +s32 mChoice_Put_String_PLAYER_NAME(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_TALK_NAME(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_TAIL(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_YEAR(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_MONTH(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_WEEK(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_DAY(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_HOUR(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_MIN(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_SEC(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_FREE(char* data, s32 idx, s32 maxSize, struct Actor* actor, s32 freeIdx); +s32 mChoice_Put_String_FREE0(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_FREE1(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_FREE2(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_FREE3(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_FREE4(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_FREE5(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_FREE6(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_FREE7(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_FREE8(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_FREE9(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_FREE10(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_FREE11(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_FREE12(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_FREE13(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_FREE14(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_FREE15(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_FREE16(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_FREE17(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_FREE18(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_FREE19(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_DETERMINATION(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_COUNTRY_NAME(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_RAMDOM_NUMBER2(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_ITEM(char* data, s32 idx, s32 maxSize, struct Actor* actor, s32 itemIdx); +s32 mChoice_Put_String_ITEM0(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_ITEM1(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_ITEM2(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_ITEM3(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String_ITEM4(char* data, s32 idx, s32 maxSize, struct Actor* actor); +s32 mChoice_Put_String(char* data, s32 idx, s32 maxSize, struct Actor* actor); +void mChoice_Change_ControlCode(char* data, s32 maxSize, struct Actor* actor); +void mChoice_Load_ChoseStringFromRom(s32 , char* str, s32 idx, struct Actor* actor); +void mChoice_no_b_set(Choice* choice); +void mChoice_sound_SENTAKU_KETTEI(void); +void mChoice_sound_SENTAKU_OPEN(void); +void mChoice_sound_CURSOL(void); +void mChoice_Main_Hide(Choice* choice, struct Game* game); +void mChoice_MainSetup_Hide(Choice* choice, struct Game* game); +s32 mChoice_Main_Appear_SetScale(Choice* choice, struct Game* game); +void mChoice_request_main_index_fromAppear(Choice* choice, struct Game* game, s32 flag); +void mChoice_Main_Appear(Choice* choice, struct Game* game); +void mChoice_MainSetup_Appear(Choice* choice, struct Game* game); +void mChoice_determimation_set(Choice* choice); +s32 mChoice_Main_Normal_SetChoice(Choice* choice, struct Game* game); +void mChoice_request_main_index_fromNormal(Choice* choice, struct Game* game, s32 flag); +void mChoice_Main_Normal(Choice* choice, struct Game* game); +void mChoice_MainSetup_Normal(Choice* choice, struct Game* game); +s32 mChoice_Main_Disappear_SetScale(Choice* choice, struct Game* game); +void mChoice_request_main_index_fromDisappear(Choice* choice, struct Game* game, s32 flag); +void mChoice_Main_Disappear(Choice* choice, struct Game* game); +void mChoice_MainSetup_Disappear(Choice* choice, struct Game* game); +void mChoice_MainSetup(Choice* choice, struct Game* game); +void mChoice_Main(Choice* choice, struct Game* game); +void mChoice_SetMatrix(Choice* choice, struct Game* game, s32 type); +void mChoice_SetMatrixDisplay(Choice* choice, struct Game* game, s32 type); +void mChoice_UnSetMatrix(void); +void mChoice_UnSetMatrixDisplay(struct Game* game, s32 type); +void mChoice_DrawWindowBody(Choice* choice, struct Game* game, s32 type); +void mChoice_DrawFont(Choice* choice, struct Game* game, s32 type); +void mChoice_Draw(Choice* choice, struct Game* game, s32 mode); +void mChoice_ct(Choice* choice, struct Game* game); +void mChoice_dt(Choice* choice, struct Game* game); #endif diff --git a/include/m_msg_main.h b/include/m_msg_main.h index fbb49f2..cbe841d 100644 --- a/include/m_msg_main.h +++ b/include/m_msg_main.h @@ -3,10 +3,17 @@ #include "ultra64.h" #include "unk.h" +#include "m_choice_main.h" struct Game_Play; +struct Actor; -UNK_PTR mMsg_Get_base_window_p(void); +typedef struct MessageWindow { + /* 0x000 */ UNK_TYPE1 unk_000[0x1B0]; + /* 0x1B0 */ Choice choiceWindow; +} MessageWindow; // size >= 0x26C + +MessageWindow* mMsg_Get_base_window_p(void); // void func_8009D200_jp(); // void func_8009D210_jp(); // void func_8009D260_jp(); @@ -93,22 +100,22 @@ size_t mMsg_Get_Length_String(char*, s32); // void func_8009EA2C_jp(); // void func_8009EB44_jp(); // void func_8009EBB0_jp(); -// void func_8009EC88_jp(); -// void func_8009ED14_jp(); -// void func_8009EDBC_jp(); -// void func_8009EE78_jp(); -// void func_8009EF00_jp(); -// void func_8009EF88_jp(); -// void func_8009F010_jp(); -// void func_8009F098_jp(); -// void func_8009F120_jp(); -// void func_8009F1A8_jp(); -// void func_8009F230_jp(); +s32 mMsg_CopyPlayerName(char*, s32, s32); +s32 mMsg_CopyTalkName(struct Actor*, char*, s32, s32); +s32 mMsg_CopyTail(struct Actor*, char*, s32, s32); +s32 mMsg_CopyYear(char*, s32, s32); +s32 mMsg_CopyMonth(char*, s32, s32); +s32 mMsg_CopyWeek(char*, s32, s32); +s32 mMsg_CopyDay(char*, s32, s32); +s32 mMsg_CopyHour(char*, s32, s32); +s32 mMsg_CopyMin(char*, s32, s32); +s32 mMsg_CopySec(char*, s32, s32); +s32 mMsg_CopyFree(MessageWindow*, s32, char*, s32, s32); // void func_8009F2EC_jp(); -// void func_8009F3A8_jp(); -// void func_8009F428_jp(); -// void func_8009F50C_jp(); -// void func_8009F5B4_jp(); +s32 mMsg_CopyDetermination(MessageWindow*, char*, s32, s32); +s32 mMsg_CopyCountryName(char*,s32,s32); +s32 mMsg_CopyRamdomNumber2(char*,s32,s32); +s32 mMsg_CopyItem(MessageWindow*, s32, char*, s32, s32); // void func_8009F670_jp(); // void func_8009F730_jp(); // void func_8009F75C_jp(); diff --git a/linker_scripts/jp/symbol_addrs_code.txt b/linker_scripts/jp/symbol_addrs_code.txt index c53d247..d3bc38c 100644 --- a/linker_scripts/jp/symbol_addrs_code.txt +++ b/linker_scripts/jp/symbol_addrs_code.txt @@ -502,94 +502,94 @@ func_80064F48_jp = 0x80064F48; // type:func func_80064F84_jp = 0x80064F84; // type:func Camera2_process = 0x80064FD8; // type:func Camera2_draw = 0x80065028; // type:func -func_80065040_jp = 0x80065040; // type:func -func_80065064_jp = 0x80065064; // type:func -func_80065158_jp = 0x80065158; // type:func -func_80065164_jp = 0x80065164; // type:func -func_80065170_jp = 0x80065170; // type:func -func_80065198_jp = 0x80065198; // type:func -func_800651A4_jp = 0x800651A4; // type:func -func_80065278_jp = 0x80065278; // type:func -func_80065348_jp = 0x80065348; // type:func -func_800653CC_jp = 0x800653CC; // type:func -func_800653DC_jp = 0x800653DC; // type:func -func_800654FC_jp = 0x800654FC; // type:func -func_80065508_jp = 0x80065508; // type:func -func_80065518_jp = 0x80065518; // type:func -func_80065528_jp = 0x80065528; // type:func -func_80065668_jp = 0x80065668; // type:func -func_8006568C_jp = 0x8006568C; // type:func -func_800656C8_jp = 0x800656C8; // type:func -func_80065704_jp = 0x80065704; // type:func -func_80065728_jp = 0x80065728; // type:func -func_8006574C_jp = 0x8006574C; // type:func -func_80065770_jp = 0x80065770; // type:func -func_80065794_jp = 0x80065794; // type:func -func_800657B8_jp = 0x800657B8; // type:func -func_800657DC_jp = 0x800657DC; // type:func -func_80065800_jp = 0x80065800; // type:func -func_8006584C_jp = 0x8006584C; // type:func -func_8006586C_jp = 0x8006586C; // type:func -func_80065890_jp = 0x80065890; // type:func -func_800658B4_jp = 0x800658B4; // type:func -func_800658D8_jp = 0x800658D8; // type:func -func_800658FC_jp = 0x800658FC; // type:func -func_80065920_jp = 0x80065920; // type:func -func_80065944_jp = 0x80065944; // type:func -func_80065968_jp = 0x80065968; // type:func -func_8006598C_jp = 0x8006598C; // type:func -func_800659B0_jp = 0x800659B0; // type:func -func_800659D4_jp = 0x800659D4; // type:func -func_800659F8_jp = 0x800659F8; // type:func -func_80065A1C_jp = 0x80065A1C; // type:func -func_80065A40_jp = 0x80065A40; // type:func -func_80065A64_jp = 0x80065A64; // type:func -func_80065A88_jp = 0x80065A88; // type:func -func_80065AAC_jp = 0x80065AAC; // type:func -func_80065AD0_jp = 0x80065AD0; // type:func -func_80065AF4_jp = 0x80065AF4; // type:func -func_80065B18_jp = 0x80065B18; // type:func -func_80065B5C_jp = 0x80065B5C; // type:func -func_80065B80_jp = 0x80065B80; // type:func -func_80065BA4_jp = 0x80065BA4; // type:func -func_80065BF0_jp = 0x80065BF0; // type:func -func_80065C10_jp = 0x80065C10; // type:func -func_80065C34_jp = 0x80065C34; // type:func -func_80065C58_jp = 0x80065C58; // type:func -func_80065C7C_jp = 0x80065C7C; // type:func -func_80065CA0_jp = 0x80065CA0; // type:func -func_80065CF8_jp = 0x80065CF8; // type:func -func_80065D90_jp = 0x80065D90; // type:func -func_80065EE8_jp = 0x80065EE8; // type:func -func_80065EF8_jp = 0x80065EF8; // type:func -func_80065F18_jp = 0x80065F18; // type:func -func_80065F38_jp = 0x80065F38; // type:func -func_80065F58_jp = 0x80065F58; // type:func -func_80065F78_jp = 0x80065F78; // type:func -func_80065F98_jp = 0x80065F98; // type:func -func_80066068_jp = 0x80066068; // type:func -func_80066094_jp = 0x80066094; // type:func -func_800660DC_jp = 0x800660DC; // type:func -func_80066130_jp = 0x80066130; // type:func -func_80066194_jp = 0x80066194; // type:func -func_800665C0_jp = 0x800665C0; // type:func -func_800665EC_jp = 0x800665EC; // type:func -func_80066634_jp = 0x80066634; // type:func -func_8006666C_jp = 0x8006666C; // type:func -func_80066740_jp = 0x80066740; // type:func -func_8006676C_jp = 0x8006676C; // type:func -func_800667B4_jp = 0x800667B4; // type:func -func_8006680C_jp = 0x8006680C; // type:func -func_8006685C_jp = 0x8006685C; // type:func -func_800668A4_jp = 0x800668A4; // type:func -func_800669A4_jp = 0x800669A4; // type:func -func_80066A60_jp = 0x80066A60; // type:func -func_80066A80_jp = 0x80066A80; // type:func -func_80066B18_jp = 0x80066B18; // type:func -func_80066BB0_jp = 0x80066BB0; // type:func -func_80066D4C_jp = 0x80066D4C; // type:func -func_80066DFC_jp = 0x80066DFC; // type:func -func_80066E34_jp = 0x80066E34; // type:func +mChoice_Get_base_window_p = 0x80065040; // type:func +mChoice_init = 0x80065064; // type:func + mChoice_Change_request_main_index = 0x80065158; // type:func + mChoice_check_main_index = 0x80065164; // type:func + mChoice_check_main_normal = 0x80065170; // type:func + mChoice_Init_choice_data = 0x80065198; // type:func + mChoice_Add_choice_data = 0x800651A4; // type:func + mChoice_Set_choice_data = 0x80065278; // type:func + mChoice_Get_MaxStringDotWidth = 0x80065348; // type:func + mChoice_Get_MaxStringDotHeight = 0x800653CC; // type:func + mChoice_Set_DisplayScaleAndDisplayPos = 0x800653DC; // type:func + mChoice_Get_ChoseNum = 0x800654FC; // type:func + mChoice_Clear_ChoseNum = 0x80065508; // type:func + mChoice_check_ct = 0x80065518; // type:func + mChoice_Get_StringDataAddressAndSize = 0x80065528; // type:func + mChoice_Put_String_PLAYER_NAME = 0x80065668; // type:func + mChoice_Put_String_TALK_NAME = 0x8006568C; // type:func + mChoice_Put_String_TAIL = 0x800656C8; // type:func + mChoice_Put_String_YEAR = 0x80065704; // type:func + mChoice_Put_String_MONTH = 0x80065728; // type:func + mChoice_Put_String_WEEK = 0x8006574C; // type:func + mChoice_Put_String_DAY = 0x80065770; // type:func + mChoice_Put_String_HOUR = 0x80065794; // type:func + mChoice_Put_String_MIN = 0x800657B8; // type:func + mChoice_Put_String_SEC = 0x800657DC; // type:func + mChoice_Put_String_FREE = 0x80065800; // type:func + mChoice_Put_String_FREE0 = 0x8006584C; // type:func + mChoice_Put_String_FREE1 = 0x8006586C; // type:func + mChoice_Put_String_FREE2 = 0x80065890; // type:func + mChoice_Put_String_FREE3 = 0x800658B4; // type:func + mChoice_Put_String_FREE4 = 0x800658D8; // type:func + mChoice_Put_String_FREE5 = 0x800658FC; // type:func + mChoice_Put_String_FREE6 = 0x80065920; // type:func + mChoice_Put_String_FREE7 = 0x80065944; // type:func + mChoice_Put_String_FREE8 = 0x80065968; // type:func + mChoice_Put_String_FREE9 = 0x8006598C; // type:func + mChoice_Put_String_FREE10 = 0x800659B0; // type:func + mChoice_Put_String_FREE11 = 0x800659D4; // type:func + mChoice_Put_String_FREE12 = 0x800659F8; // type:func + mChoice_Put_String_FREE13 = 0x80065A1C; // type:func + mChoice_Put_String_FREE14 = 0x80065A40; // type:func + mChoice_Put_String_FREE15 = 0x80065A64; // type:func + mChoice_Put_String_FREE16 = 0x80065A88; // type:func + mChoice_Put_String_FREE17 = 0x80065AAC; // type:func + mChoice_Put_String_FREE18 = 0x80065AD0; // type:func + mChoice_Put_String_FREE19 = 0x80065AF4; // type:func + mChoice_Put_String_DETERMINATION = 0x80065B18; // type:func + mChoice_Put_String_COUNTRY_NAME = 0x80065B5C; // type:func + mChoice_Put_String_RAMDOM_NUMBER2 = 0x80065B80; // type:func + mChoice_Put_String_ITEM = 0x80065BA4; // type:func + mChoice_Put_String_ITEM0 = 0x80065BF0; // type:func + mChoice_Put_String_ITEM1 = 0x80065C10; // type:func + mChoice_Put_String_ITEM2 = 0x80065C34; // type:func + mChoice_Put_String_ITEM3 = 0x80065C58; // type:func + mChoice_Put_String_ITEM4 = 0x80065C7C; // type:func + mChoice_Put_String = 0x80065CA0; // type:func + mChoice_Change_ControlCode = 0x80065CF8; // type:func + mChoice_Load_ChoseStringFromRom = 0x80065D90; // type:func + mChoice_no_b_set = 0x80065EE8; // type:func + mChoice_sound_SENTAKU_KETTEI = 0x80065EF8; // type:func + mChoice_sound_SENTAKU_OPEN = 0x80065F18; // type:func + mChoice_sound_CURSOL = 0x80065F38; // type:func + mChoice_Main_Hide = 0x80065F58; // type:func + mChoice_MainSetup_Hide = 0x80065F78; // type:func + mChoice_Main_Appear_SetScale = 0x80065F98; // type:func + mChoice_request_main_index_fromAppear = 0x80066068; // type:func + mChoice_Main_Appear = 0x80066094; // type:func + mChoice_MainSetup_Appear = 0x800660DC; // type:func + mChoice_determimation_set = 0x80066130; // type:func + mChoice_Main_Normal_SetChoice = 0x80066194; // type:func + mChoice_request_main_index_fromNormal = 0x800665C0; // type:func + mChoice_Main_Normal = 0x800665EC; // type:func + mChoice_MainSetup_Normal = 0x80066634; // type:func + mChoice_Main_Disappear_SetScale = 0x8006666C; // type:func + mChoice_request_main_index_fromDisappear = 0x80066740; // type:func + mChoice_Main_Disappear = 0x8006676C; // type:func + mChoice_MainSetup_Disappear = 0x800667B4; // type:func + mChoice_MainSetup = 0x8006680C; // type:func + mChoice_Main = 0x8006685C; // type:func + mChoice_SetMatrix = 0x800668A4; // type:func + mChoice_SetMatrixDisplay = 0x800669A4; // type:func + mChoice_UnSetMatrix = 0x80066A60; // type:func + mChoice_UnSetMatrixDisplay = 0x80066A80; // type:func + mChoice_DrawWindowBody = 0x80066B18; // type:func + mChoice_DrawFont = 0x80066BB0; // type:func + mChoice_Draw = 0x80066D4C; // type:func + mChoice_ct = 0x80066DFC; // type:func + mChoice_dt = 0x80066E34; // type:func clip_clear = 0x80066E50; // type:func mCkRh_GokiFamilyCount2Good = 0x80066E90; // type:func mCkRh_InitGokiSaveData_1Room = 0x80066EB8; // type:func @@ -1531,7 +1531,7 @@ func_80090140_jp = 0x80090140; // type:func func_80090178_jp = 0x80090178; // type:func func_80090188_jp = 0x80090188; // type:func func_8009028C_jp = 0x8009028C; // type:func -func_800902CC_jp = 0x800902CC; // type:func +mFont_GetStringWidth = 0x800902CC; // type:func func_8009034C_jp = 0x8009034C; // type:func func_800903A8_jp = 0x800903A8; // type:func func_800903CC_jp = 0x800903CC; // type:func @@ -1582,7 +1582,7 @@ func_80091F98_jp = 0x80091F98; // type:func func_80091FCC_jp = 0x80091FCC; // type:func func_80092000_jp = 0x80092000; // type:func func_80092034_jp = 0x80092034; // type:func -func_800921D0_jp = 0x800921D0; // type:func +mFont_SetMarkChar = 0x800921D0; // type:func func_80092440_jp = 0x80092440; // type:func func_80092468_jp = 0x80092468; // type:func func_800924CC_jp = 0x800924CC; // type:func @@ -1988,22 +1988,22 @@ func_8009EA18_jp = 0x8009EA18; // type:func func_8009EA2C_jp = 0x8009EA2C; // type:func func_8009EB44_jp = 0x8009EB44; // type:func func_8009EBB0_jp = 0x8009EBB0; // type:func -func_8009EC88_jp = 0x8009EC88; // type:func -func_8009ED14_jp = 0x8009ED14; // type:func -func_8009EDBC_jp = 0x8009EDBC; // type:func -func_8009EE78_jp = 0x8009EE78; // type:func -func_8009EF00_jp = 0x8009EF00; // type:func -func_8009EF88_jp = 0x8009EF88; // type:func -func_8009F010_jp = 0x8009F010; // type:func -func_8009F098_jp = 0x8009F098; // type:func -func_8009F120_jp = 0x8009F120; // type:func -func_8009F1A8_jp = 0x8009F1A8; // type:func -func_8009F230_jp = 0x8009F230; // type:func +mMsg_CopyPlayerName = 0x8009EC88; // type:func +mMsg_CopyTalkName = 0x8009ED14; // type:func +mMsg_CopyTail = 0x8009EDBC; // type:func +mMsg_CopyYear = 0x8009EE78; // type:func +mMsg_CopyMonth = 0x8009EF00; // type:func +mMsg_CopyWeek = 0x8009EF88; // type:func +mMsg_CopyDay = 0x8009F010; // type:func +mMsg_CopyHour = 0x8009F098; // type:func +mMsg_CopyMin = 0x8009F120; // type:func +mMsg_CopySec = 0x8009F1A8; // type:func +mMsg_CopyFree = 0x8009F230; // type:func func_8009F2EC_jp = 0x8009F2EC; // type:func -func_8009F3A8_jp = 0x8009F3A8; // type:func -func_8009F428_jp = 0x8009F428; // type:func -func_8009F50C_jp = 0x8009F50C; // type:func -func_8009F5B4_jp = 0x8009F5B4; // type:func +mMsg_CopyDetermination = 0x8009F3A8; // type:func +mMsg_CopyCountryName = 0x8009F428; // type:func +mMsg_CopyRamdomNumber2 = 0x8009F50C; // type:func +mMsg_CopyItem = 0x8009F5B4; // type:func func_8009F670_jp = 0x8009F670; // type:func func_8009F730_jp = 0x8009F730; // type:func func_8009F75C_jp = 0x8009F75C; // type:func @@ -4229,10 +4229,10 @@ D_80102A48_jp = 0x80102A48; // D_80102A80_jp = 0x80102A80; // D_80102C04_jp = 0x80102C04; // D_80102C14_jp = 0x80102C14; // -D_80102C28_jp = 0x80102C28; // -D_80102C68_jp = 0x80102C68; // -D_80103C68_jp = 0x80103C68; // -D_80103CE0_jp = 0x80103CE0; // +con_sentaku2_v = 0x80102C28; // +con_waku_swaku3_tex = 0x80102C68; // +con_sentaku2_modelT = 0x80103C68; // +mChoice_init_disp = 0x80103CE0; // CanLookGokiCount = 0x80103D50; // type:s32 D_80103D55_jp = 0x80103D55; // type:u8 D_80103D59_jp = 0x80103D59; // type:u8 diff --git a/src/code/m_choice_main.c b/src/code/m_choice_main.c new file mode 100644 index 0000000..d4a7b38 --- /dev/null +++ b/src/code/m_choice_main.c @@ -0,0 +1,1038 @@ +#include "m_choice_main.h" +#include "m_msg_main.h" +#include "game.h" +#include "m_actor.h" +#include "gfx.h" +#include "m_std_dma.h" +#include "audio.h" +#include "m_lib.h" +#include "sys_matrix.h" +#include "6B3DC0.h" + +extern u32 D_D06000[]; +extern u32 D_D05000[]; + +Choice* mChoice_Get_base_window_p() { + return &mMsg_Get_base_window_p()->choiceWindow; +} + +void mChoice_init(Choice* choice, UNUSED Game* game) { + choice->centerX = 191.0f; + choice->centerY = 83.0f; + + choice->textX = 104.0; + choice->textY = 96.0f; + + choice->textColor.r = 180; + choice->textColor.g = 150; + choice->textColor.b = 110; + choice->textColor.a = 255; + + choice->textScaleX = 1.0f; + choice->textScaleY = 1.0f; + + choice->scaleX = 1.0f; + choice->scaleY = 1.0f; + + choice->data.choiceNum = Choice_CHOICE_MAX; + choice->selectedChoiceIdx = Choice_CHOICE0; + + choice->selectedChoiceTextColor.r = 120; + choice->selectedChoiceTextColor.g = 50; + choice->selectedChoiceTextColor.b = 50; + choice->selectedChoiceTextColor.a = 255; + + choice->backgroundColor.r = 0; + choice->backgroundColor.g = 195; + choice->backgroundColor.b = 185; + choice->backgroundColor.a = 255; + + choice->choiceAutomoveTimer = 0.0f; + + choice->scale = 0.0f; + + choice->mainIdx = 0; + choice->requestedMainIdx = -1; + choice->isWindowVisible = FALSE; + choice->isFontVisible = FALSE; + choice->choiceAutomoveType = Choice_AUTOMOVE_STOPPED; + choice->choiceAutomoveTimer = 0.0f; + choice->unk_D4 = 232.0f; + choice->timer = 0.0f; + choice->noBFlag = FALSE; + + choice->unk_D8 = 104.0f; +} + +void mChoice_Change_request_main_index(Choice* choice, s32 idx) { + choice->requestedMainIdx = idx; +} + +s32 mChoice_check_main_index(Choice* choice) { + return choice->mainIdx; +} + +s32 mChoice_check_main_normal(Choice* choice) { + return mChoice_check_main_index(choice) == 2; +} + +void mChoice_Init_choice_data(Choice* choice) { + choice->data.choiceNum = Choice_CHOICE0; +} + +s32 mChoice_Add_choice_data(Choice* choice, char* str, s32 max_len) { + if (str != NULL && max_len > 0 && max_len < 11) { + s32 len; + int idx; + s32* t; + char* dst; + s32 i; + + t = &choice->data.choiceNum; + if (choice->data.choiceNum < Choice_CHOICE_MAX) { + idx = *t; + len = mMsg_Get_Length_String(str, max_len); + dst = choice->data.strings[idx]; + + for (i = 0; i < len; i++) { + *dst++ = *str++; + } + + choice->data.stringLens[idx] = len; + *t += 1; + return idx; + } + } + + return -1; +} + +void mChoice_Set_choice_data(Choice* choice, char* str0, s32 str0len, char* str1, s32 str1len, char* str2, s32 str2len, + char* str3, s32 str3len) { + mChoice_Init_choice_data(choice); + + if (str0 != NULL && str0len > 0 && str0len <= Choice_CHOICE_STRING_LEN) { + mChoice_Add_choice_data(choice, str0, str0len); + } + + if (str1 != NULL && str1len > 0 && str1len <= Choice_CHOICE_STRING_LEN) { + mChoice_Add_choice_data(choice, str1, str1len); + } + + if (str2 != NULL && str2len > 0 && str2len <= Choice_CHOICE_STRING_LEN) { + mChoice_Add_choice_data(choice, str2, str2len); + } + + if (str3 != NULL && str3len > 0 && str3len <= Choice_CHOICE_STRING_LEN) { + mChoice_Add_choice_data(choice, str3, str3len); + } +} + +s32 mChoice_Get_MaxStringDotWidth(Choice* choice) { + s32 i; + s32 choiceNum = choice->data.choiceNum; + s32 maxWidth = 0; + + for (i = 0; i < choiceNum; i++) { + char* str = choice->data.strings[i]; + s32 len = choice->data.stringLens[i]; + s32 width = mFont_GetStringWidth(str, len, 0); + + if (width > maxWidth) { + maxWidth = width; + } + } + + return maxWidth; +} + +s32 mChoice_Get_MaxStringDotHeight(Choice* choice) { + return choice->data.choiceNum * 16; +} + +void mChoice_Set_DisplayScaleAndDisplayPos(Choice* choice) { + f32 dotW = ((f32)mChoice_Get_MaxStringDotWidth(choice) - 24) / 96; + f32 dotH = ((f32)mChoice_Get_MaxStringDotHeight(choice) - 32) / 32; + + { + f32 scaleX = (0.5833334f * dotW); + f32 scaleY = (0.3142857f * dotH); + + choice->scaleX = 0.41666666f + scaleX; + choice->scaleY = 0.6857143f + scaleY; + } + + { + f32 t0 = (-48.0f * dotW); + f32 t1 = (-20.057144f * dotH); + + choice->textX = 152.0f + t0; + choice->textY = 105.0f + t1; + } + + { + f32 t0 = (-35.0f * dotW); + f32 t1 = (20.057144f * dotH); + + choice->centerX = 242.0f; + choice->centerY = 169.0f; + choice->centerXBegin = choice->centerX; + choice->centerYBegin = choice->centerY; + choice->centerXTarget = choice->centerX + t0; + choice->centerYTarget = choice->centerY + t1; + } +} + +s32 mChoice_Get_ChoseNum(Choice* choice) { + return choice->data.selectedChoiceIdx; +} + +void mChoice_Clear_ChoseNum(Choice* choice) { + choice->data.selectedChoiceIdx = -1; +} + +void mChoice_check_ct(UNUSED Choice* choice, UNUSED Game* game) { +} +void mChoice_Get_StringDataAddressAndSize(s32 idx, u32** addr, u32* size) { + s32 sizeCalc; + s32 temp0; + s32 temp1; + u32 vram[3]; + + if (idx >= 0 && idx < 460) { + u32 vrom; + if (idx & 1) { + temp0 = idx - 1; + + DmaMgr_RequestSyncDebug(vram, (uintptr_t)&D_D06000[temp0], 8, "../m_choice_main.c", 454); + vrom = vram[0]; + sizeCalc = vram[1] - vrom; + } else if (idx == 0) { + DmaMgr_RequestSyncDebug(vram, (uintptr_t)&D_D06000[0], 8, "../m_choice_main.c", 461); + vrom = 0; + sizeCalc = vram[0]; + } else { + temp1 = idx - 2; + + DmaMgr_RequestSyncDebug(vram, (uintptr_t)&D_D06000[temp1], 16, "../m_choice_main.c", 467); + vrom = vram[1]; + sizeCalc = vram[2] - vrom; + } + + if (sizeCalc < 11) { + *addr = (u32*)((uintptr_t)vrom + (uintptr_t)&D_D05000); + *size = sizeCalc; + } else { + *addr = NULL; + *size = NULL; + } + } else { + *addr = NULL; + *size = NULL; + } +} + +s32 mChoice_Put_String_PLAYER_NAME(char* data, s32 idx, s32 maxSize, UNUSED Actor* actor) { + return mMsg_CopyPlayerName(data, idx, maxSize); +} + +s32 mChoice_Put_String_TALK_NAME(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mMsg_CopyTalkName(actor, data, idx, maxSize); +} + +s32 mChoice_Put_String_TAIL(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mMsg_CopyTail(actor, data, idx, maxSize); +} + +s32 mChoice_Put_String_YEAR(char* data, s32 idx, s32 maxSize, UNUSED Actor* actor) { + return mMsg_CopyYear(data, idx, maxSize); +} + +s32 mChoice_Put_String_MONTH(char* data, s32 idx, s32 maxSize, UNUSED Actor* actor) { + return mMsg_CopyMonth(data, idx, maxSize); +} + +s32 mChoice_Put_String_WEEK(char* data, s32 idx, s32 maxSize, UNUSED Actor* actor) { + return mMsg_CopyWeek(data, idx, maxSize); +} + +s32 mChoice_Put_String_DAY(char* data, s32 idx, s32 maxSize, UNUSED Actor* actor) { + return mMsg_CopyDay(data, idx, maxSize); +} + +s32 mChoice_Put_String_HOUR(char* data, s32 idx, s32 maxSize, UNUSED Actor* actor) { + return mMsg_CopyHour(data, idx, maxSize); +} + +s32 mChoice_Put_String_MIN(char* data, s32 idx, s32 maxSize, UNUSED Actor* actor) { + return mMsg_CopyMin(data, idx, maxSize); +} + +s32 mChoice_Put_String_SEC(char* data, s32 idx, s32 maxSize, UNUSED Actor* actor) { + return mMsg_CopySec(data, idx, maxSize); +} + +s32 mChoice_Put_String_FREE(char* data, s32 idx, s32 maxSize, UNUSED Actor* actor, s32 freeIdx) { + return mMsg_CopyFree(mMsg_Get_base_window_p(), freeIdx, data, idx, maxSize); +} + +s32 mChoice_Put_String_FREE0(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mChoice_Put_String_FREE(data, idx, maxSize, actor, 0); +} + +s32 mChoice_Put_String_FREE1(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mChoice_Put_String_FREE(data, idx, maxSize, actor, 1); +} + +s32 mChoice_Put_String_FREE2(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mChoice_Put_String_FREE(data, idx, maxSize, actor, 2); +} + +s32 mChoice_Put_String_FREE3(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mChoice_Put_String_FREE(data, idx, maxSize, actor, 3); +} + +s32 mChoice_Put_String_FREE4(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mChoice_Put_String_FREE(data, idx, maxSize, actor, 4); +} + +s32 mChoice_Put_String_FREE5(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mChoice_Put_String_FREE(data, idx, maxSize, actor, 5); +} + +s32 mChoice_Put_String_FREE6(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mChoice_Put_String_FREE(data, idx, maxSize, actor, 6); +} + +s32 mChoice_Put_String_FREE7(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mChoice_Put_String_FREE(data, idx, maxSize, actor, 7); +} + +s32 mChoice_Put_String_FREE8(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mChoice_Put_String_FREE(data, idx, maxSize, actor, 8); +} + +s32 mChoice_Put_String_FREE9(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mChoice_Put_String_FREE(data, idx, maxSize, actor, 9); +} + +s32 mChoice_Put_String_FREE10(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mChoice_Put_String_FREE(data, idx, maxSize, actor, 10); +} + +s32 mChoice_Put_String_FREE11(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mChoice_Put_String_FREE(data, idx, maxSize, actor, 11); +} + +s32 mChoice_Put_String_FREE12(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mChoice_Put_String_FREE(data, idx, maxSize, actor, 12); +} + +s32 mChoice_Put_String_FREE13(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mChoice_Put_String_FREE(data, idx, maxSize, actor, 13); +} + +s32 mChoice_Put_String_FREE14(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mChoice_Put_String_FREE(data, idx, maxSize, actor, 14); +} + +s32 mChoice_Put_String_FREE15(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mChoice_Put_String_FREE(data, idx, maxSize, actor, 15); +} + +s32 mChoice_Put_String_FREE16(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mChoice_Put_String_FREE(data, idx, maxSize, actor, 16); +} + +s32 mChoice_Put_String_FREE17(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mChoice_Put_String_FREE(data, idx, maxSize, actor, 17); +} + +s32 mChoice_Put_String_FREE18(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mChoice_Put_String_FREE(data, idx, maxSize, actor, 18); +} + +s32 mChoice_Put_String_FREE19(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mChoice_Put_String_FREE(data, idx, maxSize, actor, 19); +} + +s32 mChoice_Put_String_DETERMINATION(char* data, s32 idx, s32 maxSize, UNUSED Actor* actor) { + return mMsg_CopyDetermination(mMsg_Get_base_window_p(), data, idx, maxSize); +} + +s32 mChoice_Put_String_COUNTRY_NAME(char* data, s32 idx, s32 maxSize, UNUSED Actor* actor) { + return mMsg_CopyCountryName(data, idx, maxSize); +} + +s32 mChoice_Put_String_RAMDOM_NUMBER2(char* data, s32 idx, s32 maxSize, UNUSED Actor* actor) { + return mMsg_CopyRamdomNumber2(data, idx, maxSize); +} + +s32 mChoice_Put_String_ITEM(char* data, s32 idx, s32 maxSize, UNUSED Actor* actor, s32 itemIdx) { + return mMsg_CopyItem(mMsg_Get_base_window_p(), itemIdx, data, idx, maxSize); +} + +s32 mChoice_Put_String_ITEM0(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mChoice_Put_String_ITEM(data, idx, maxSize, actor, 0); +} + +s32 mChoice_Put_String_ITEM1(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mChoice_Put_String_ITEM(data, idx, maxSize, actor, 1); +} + +s32 mChoice_Put_String_ITEM2(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mChoice_Put_String_ITEM(data, idx, maxSize, actor, 2); +} + +s32 mChoice_Put_String_ITEM3(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mChoice_Put_String_ITEM(data, idx, maxSize, actor, 3); +} + +s32 mChoice_Put_String_ITEM4(char* data, s32 idx, s32 maxSize, Actor* actor) { + return mChoice_Put_String_ITEM(data, idx, maxSize, actor, 4); +} + +typedef s32 (*ChoicePutStringProc)(char*, s32, s32, Actor*); + +s32 mChoice_Put_String(char* data, s32 idx, s32 maxSize, Actor* actor) { + static ChoicePutStringProc proc[] = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + &mChoice_Put_String_PLAYER_NAME, + &mChoice_Put_String_TALK_NAME, + &mChoice_Put_String_TAIL, + &mChoice_Put_String_YEAR, + &mChoice_Put_String_MONTH, + &mChoice_Put_String_WEEK, + &mChoice_Put_String_DAY, + &mChoice_Put_String_HOUR, + &mChoice_Put_String_MIN, + &mChoice_Put_String_SEC, + &mChoice_Put_String_FREE0, + &mChoice_Put_String_FREE1, + &mChoice_Put_String_FREE2, + &mChoice_Put_String_FREE3, + &mChoice_Put_String_FREE4, + &mChoice_Put_String_FREE5, + &mChoice_Put_String_FREE6, + &mChoice_Put_String_FREE7, + &mChoice_Put_String_FREE8, + &mChoice_Put_String_FREE9, + &mChoice_Put_String_DETERMINATION, + &mChoice_Put_String_COUNTRY_NAME, + &mChoice_Put_String_RAMDOM_NUMBER2, + &mChoice_Put_String_ITEM0, + &mChoice_Put_String_ITEM1, + &mChoice_Put_String_ITEM2, + &mChoice_Put_String_ITEM3, + &mChoice_Put_String_ITEM4, + &mChoice_Put_String_FREE10, + &mChoice_Put_String_FREE11, + &mChoice_Put_String_FREE12, + &mChoice_Put_String_FREE13, + &mChoice_Put_String_FREE14, + &mChoice_Put_String_FREE15, + &mChoice_Put_String_FREE16, + &mChoice_Put_String_FREE17, + &mChoice_Put_String_FREE18, + &mChoice_Put_String_FREE19, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + }; + + s32 type = data[idx + 1]; + + if (type >= 0 && type < 97 && proc[type] != NULL) { + return (*proc[type])(data, idx, maxSize, actor); + } + + return maxSize; +} + +void mChoice_Change_ControlCode(char* data, s32 maxSize, Actor* actor) { + s32 idx; + s32 newSize; + + newSize = maxSize; + idx = 0; + + for (idx = 0; idx < newSize;) { + char* src; + char code; + + src = &data[idx]; + code = *src; + if (code == 0x7F) { + newSize = mChoice_Put_String(data, idx, newSize, actor); + } else { + idx++; + }; + }; +} + +void mChoice_Load_ChoseStringFromRom(UNUSED s32 unused, char* str, s32 idx, Actor* actor) { + if (idx >= 0 && idx < 460) { + u32* addr; + u32 size; + + mChoice_Get_StringDataAddressAndSize(idx, &addr, &size); + + if (size == 0) { + mem_clear((u8*)str, Choice_CHOICE_STRING_LEN, ' '); + } else if (addr != NULL) { + char vram[29]; + s32 alignedSize = ((u32)addr & ~7); + s32 ofs = (u32)addr - alignedSize; + + DmaMgr_RequestSyncDebug(&vram, alignedSize, ALIGN8(ofs + size), "../m_choice_main.c", 1168); + + { + s32 len; + char* dst; + char* src; + s32 i; + + if (size < Choice_CHOICE_STRING_LEN) { + len = size; + } else { + len = Choice_CHOICE_STRING_LEN; + } + + dst = str; + src = (char*)&vram[ofs]; + + for (i = 0; i < len; i++) { + *dst++ = *src++; + } + + for (; i < Choice_CHOICE_STRING_LEN; i++) { + *dst++ = ' '; + } + + mChoice_Change_ControlCode(str, Choice_CHOICE_STRING_LEN, actor); + } + } + } +} +void mChoice_no_b_set(Choice* choice) { + choice->noBFlag = TRUE; +} + +void mChoice_sound_SENTAKU_KETTEI() { + sAdo_SysTrgStart(0xD); +} + +void mChoice_sound_SENTAKU_OPEN() { + sAdo_SysTrgStart(0xC); +} + +void mChoice_sound_CURSOL() { + sAdo_SysTrgStart(1); +} + +void mChoice_Main_Hide(Choice* choice, Game* game) { + mChoice_MainSetup(choice, game); +} + +void mChoice_MainSetup_Hide(Choice* choice, Game* game) { + mChoice_init(choice, game); +} + +s32 mChoice_Main_Appear_SetScale(Choice* choice, UNUSED Game* game) { + f32 max = 5.1f; + + if (choice->timer < max) { + f32 scale; + + choice->timer += 1.0f; + scale = get_percent_forAccelBrake(choice->timer, 0.0f, max, 0.0f, 0.0f); + choice->scale = scale; + choice->centerX = choice->centerXBegin + scale * (choice->centerXTarget - choice->centerXBegin); + choice->centerY = choice->centerYBegin + scale * (choice->centerYTarget - choice->centerYBegin); + return FALSE; + } else { + choice->timer = 0.0f; + choice->scale = 1.0f; + choice->centerX = choice->centerXTarget; + choice->centerY = choice->centerYTarget; + return TRUE; + } +} + +void mChoice_request_main_index_fromAppear(Choice* choice, UNUSED Game* game, s32 flag) { + if (flag) { + mChoice_Change_request_main_index(choice, 2); + } +} + +void mChoice_Main_Appear(Choice* choice, Game* game) { + s32 flag = mChoice_Main_Appear_SetScale(choice, game); + + mChoice_request_main_index_fromAppear(choice, game, flag); + mChoice_MainSetup(choice, game); +} + +void mChoice_MainSetup_Appear(Choice* choice, UNUSED Game* game) { + choice->scale = 0.0f; + choice->mainIdx = 1; + choice->requestedMainIdx = -1; + choice->isWindowVisible = TRUE; + choice->timer = 0.0f; + mChoice_Clear_ChoseNum(choice); + mChoice_sound_SENTAKU_OPEN(); + mChoice_Set_DisplayScaleAndDisplayPos(choice); +} + +void mChoice_determimation_set(Choice* choice) { + ChoiceData* choiceData = &choice->data; + s32 idx = choice->selectedChoiceIdx; + + bcopy(choiceData->strings[idx], choiceData->determinationString, Choice_CHOICE_STRING_LEN); + choiceData->determinationLenght = choiceData->stringLens[idx]; + choiceData->selectedChoiceIdx = idx; +} + +s32 mChoice_Main_Normal_SetChoice(Choice* choice, UNUSED Game* game) { + s32 res = FALSE; + + if (chkTrigger(A_BUTTON)) { + mChoice_determimation_set(choice); + res = TRUE; + } else if (choice->noBFlag && chkTrigger(B_BUTTON)) { + choice->selectedChoiceIdx = choice->data.choiceNum - 1; + mChoice_determimation_set(choice); + res = TRUE; + } else { + f32 percent = gamePT->controller.adjustedY; + s32* choiceAutomove = &choice->choiceAutomoveType; + f32* choiceAutomoveTimer = &choice->choiceAutomoveTimer; + s32* selectedIdx = &choice->selectedChoiceIdx; + s32 sfx = FALSE; + + switch (*choiceAutomove) { + case Choice_AUTOMOVE_INCREMENT_WAIT: { + if (percent < 0.0f || chkButton(D_CBUTTONS)) { + (*choiceAutomoveTimer) += 1.0f; + + if (*choiceAutomoveTimer >= 9.0f) { + *choiceAutomoveTimer = 0.0f; + *choiceAutomove = Choice_AUTOMOVE_INCREMENT; + (*selectedIdx)++; + sfx = TRUE; + } + } else { + *choiceAutomove = Choice_AUTOMOVE_STOPPED; + *choiceAutomoveTimer = 0.0f; + } + + break; + } + + case Choice_AUTOMOVE_INCREMENT: { + if (percent < 0.0f || chkButton(D_CBUTTONS)) { + (*choiceAutomoveTimer) += 1.0f; + + if (*choiceAutomoveTimer >= 4.5f) { + *choiceAutomoveTimer = 0.0f; + (*selectedIdx)++; + sfx = TRUE; + } + } else { + *choiceAutomove = Choice_AUTOMOVE_STOPPED; + *choiceAutomoveTimer = 0.0f; + } + + break; + } + + case Choice_AUTOMOVE_DECREMENT_WAIT: { + if (percent > 0.0f || chkButton(U_CBUTTONS)) { + (*choiceAutomoveTimer) += 1.0f; + + if (*choiceAutomoveTimer >= 9.0f) { + *choiceAutomoveTimer = 0.0f; + *choiceAutomove = Choice_AUTOMOVE_DECREMENT; + (*selectedIdx)--; + sfx = TRUE; + } + } else { + *choiceAutomove = Choice_AUTOMOVE_STOPPED; + *choiceAutomoveTimer = 0.0f; + } + + break; + } + + case Choice_AUTOMOVE_DECREMENT: { + if (percent > 0.0f || chkButton(U_CBUTTONS)) { + (*choiceAutomoveTimer) += 1.0f; + + if (*choiceAutomoveTimer >= 4.5f) { + *choiceAutomoveTimer = 0.0f; + (*selectedIdx)--; + sfx = TRUE; + } + } else { + *choiceAutomove = Choice_AUTOMOVE_STOPPED; + *choiceAutomoveTimer = 0.0f; + } + + break; + } + + default: { + if (percent > 0.0f || chkTrigger(U_CBUTTONS)) { + *choiceAutomove = Choice_AUTOMOVE_DECREMENT_WAIT; + *choiceAutomoveTimer = 0.0f; + (*selectedIdx)--; + sfx = TRUE; + } else if (percent < 0.0f || chkTrigger(D_CBUTTONS)) { + *choiceAutomove = Choice_AUTOMOVE_INCREMENT_WAIT; + *choiceAutomoveTimer = 0.0f; + (*selectedIdx)++; + sfx = TRUE; + } + + break; + } + } + + if ((*selectedIdx) < 0) { + *selectedIdx = 0; + } else if ((*selectedIdx) >= choice->data.choiceNum) { + *selectedIdx = choice->data.choiceNum - 1; + } else { + if (sfx) { + mChoice_sound_CURSOL(); + } + } + } + + return res; +} + +void mChoice_request_main_index_fromNormal(Choice* choice, UNUSED Game* game, s32 flag) { + if (flag) { + mChoice_Change_request_main_index(choice, 3); + } +} + +void mChoice_Main_Normal(Choice* choice, Game* game) { + s32 flag = mChoice_Main_Normal_SetChoice(choice, game); + + mChoice_request_main_index_fromNormal(choice, game, flag); + mChoice_MainSetup(choice, game); +} + +void mChoice_MainSetup_Normal(Choice* choice, UNUSED Game* game) { + choice->scale = 1.0f; + choice->timer = 0.0f; + choice->requestedMainIdx = -1; + choice->mainIdx = 2; + choice->isFontVisible = TRUE; +} + +s32 mChoice_Main_Disappear_SetScale(Choice* choice, UNUSED Game* game) { + f32 max = 5.1f; + + if (choice->timer < max) { + f32 scale; + + choice->timer += 1.0f; + scale = 1.0f - get_percent_forAccelBrake(choice->timer, 0.0f, max, 0.0f, 0.0f); + choice->scale = scale; + choice->centerX = choice->centerXBegin + scale * (choice->centerXTarget - choice->centerXBegin); + choice->centerY = choice->centerYBegin + scale * (choice->centerYTarget - choice->centerYBegin); + return FALSE; + } else { + choice->timer = 0.0f; + choice->scale = 0.0f; + choice->centerX = choice->centerXBegin; + choice->centerY = choice->centerYBegin; + return TRUE; + } +} + +void mChoice_request_main_index_fromDisappear(Choice* choice, UNUSED Game* game, s32 flag) { + if (flag) { + mChoice_Change_request_main_index(choice, 0); + } +} +void mChoice_Main_Disappear(Choice* choice, Game* game) { + s32 flag = mChoice_Main_Disappear_SetScale(choice, game); + + mChoice_request_main_index_fromDisappear(choice, game, flag); + mChoice_MainSetup(choice, game); +} + +void mChoice_MainSetup_Disappear(Choice* choice, UNUSED Game* game) { + mChoice_sound_SENTAKU_KETTEI(); + choice->mainIdx = 3; + choice->requestedMainIdx = -1; + choice->isWindowVisible = TRUE; + choice->isFontVisible = FALSE; + choice->scale = 1.0f; + choice->timer = 0.0f; +} + +typedef void (*ChoiceMainProc)(Choice*, Game*); + +void mChoice_MainSetup(Choice* choice, Game* game) { + static ChoiceMainProc proc[] = { + &mChoice_MainSetup_Hide, + &mChoice_MainSetup_Appear, + &mChoice_MainSetup_Normal, + &mChoice_MainSetup_Disappear, + }; + + s32 index = choice->requestedMainIdx; + + if (index < 0) { + return; + } else if (index < 0 || index >= 4 || proc[index] == NULL) { + return; + } + + (*proc[index])(choice, game); +} + +void mChoice_Main(Choice* choice, Game* game) { + static ChoiceMainProc proc[] = { + &mChoice_Main_Hide, + &mChoice_Main_Appear, + &mChoice_Main_Normal, + &mChoice_Main_Disappear, + }; + + s32 index = choice->mainIdx; + + if (index < 0 || index >= 4 || proc[index] == NULL) { + return; + } + + (*proc[index])(choice, game); +} + +void mChoice_SetMatrix(Choice* choice, Game* game, s32 type) { + GraphicsContext* graph = game->gfxCtx; + f32 scale = choice->scale; + f32 x = (choice->centerX - 160.0f) * 16.0f; + f32 y = (-choice->centerY + 120.0f) * 16.0f; + + Matrix_push(); + Matrix_translate(x, y, 0.0f, 1); + Matrix_scale(scale, scale, 1.0f, 1); + + OPEN_DISPS(graph); + + if (type == 1) { + gSPMatrix(FONT_DISP++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } else { + gSPMatrix(POLY_OPA_DISP++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } + + CLOSE_DISPS(graph); +} + +void mChoice_SetMatrixDisplay(Choice* choice, Game* game, s32 type) { + GraphicsContext* graph = game->gfxCtx; + f32 scaleX = choice->scaleX; + f32 scaleY = choice->scaleY; + + Matrix_push(); + Matrix_scale(scaleX, scaleY, 1.0f, 1); + + OPEN_DISPS(graph); + + if (type == 1) { + gSPMatrix(FONT_DISP++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } else { + gSPMatrix(POLY_OPA_DISP++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } + + CLOSE_DISPS(graph); +} + +void mChoice_UnSetMatrix() { + Matrix_pull(); +} + +void mChoice_UnSetMatrixDisplay(Game* game, s32 type) { + GraphicsContext* graph = game->gfxCtx; + + Matrix_pull(); + + OPEN_DISPS(graph); + + if (type == 1) { + gSPMatrix(FONT_DISP++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } else { + gSPMatrix(POLY_OPA_DISP++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } + + CLOSE_DISPS(graph); +} + +extern Vtx con_sentaku2_v[]; +#include "assets/jp/code/m_choice_main/con_sentaku2_v.vtx.inc.c" + +u8 con_waku_swaku3_tex[] = { +#include "assets/jp/code/m_choice_main/con_waku_swaku3_tex.i4.inc.c" +}; + +Gfx con_sentaku2_modelT[] = { + gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), + gsDPPipeSync(), + gsDPSetPrimColor(0, 255, 255, 255, 155, 255), + gsDPPipeSync(), + gsDPSetTextureLUT(G_TT_NONE), + gsDPLoadTextureBlock_4b(con_waku_swaku3_tex, G_IM_FMT_I, 128, 64, 15, G_TX_MIRROR | G_TX_WRAP, + G_TX_MIRROR | G_TX_WRAP, 7, 6, G_TX_NOLOD, G_TX_NOLOD), + gsSPVertex(con_sentaku2_v, 4, 0), + gsSP2Triangles(0, 1, 2, 0, 0, 2, 3, 0), + gsSPEndDisplayList(), +}; + +Gfx mChoice_init_disp[] = { + gsDPPipeSync(), + gsSPClearGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | + G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH), + gsDPSetTextureLOD(G_TL_TILE), + gsDPSetTextureConvert(G_TC_FILT), + gsDPSetTextureFilter(G_TF_BILERP), + gsDPSetCycleType(G_CYC_1CYCLE), + gsDPSetTexturePersp(G_TP_PERSP), + gsDPSetAlphaDither(G_AD_DISABLE), + gsDPSetColorDither(G_CD_DISABLE), + gsDPSetCombineKey(G_CK_NONE), + gsDPSetCombineLERP(0, 0, 0, PRIMITIVE, 0, 0, 0, TEXEL0, 0, 0, 0, PRIMITIVE, 0, 0, 0, TEXEL0), + gsDPSetRenderMode(G_RM_XLU_SURF, G_RM_XLU_SURF2), + gsSPEndDisplayList(), +}; + +void mChoice_DrawWindowBody(UNUSED Choice* choice, Game* game, s32 type) { + GraphicsContext* graph = game->gfxCtx; + + OPEN_DISPS(graph); + + if (type == 1) { + gSPDisplayList(FONT_DISP++, mChoice_init_disp); + gSPDisplayList(FONT_DISP++, con_sentaku2_modelT); + } else { + gSPDisplayList(POLY_OPA_DISP++, mChoice_init_disp); + gSPDisplayList(POLY_OPA_DISP++, con_sentaku2_modelT); + } + + CLOSE_DISPS(graph); +} + +void mChoice_DrawFont(Choice* choice, Game* game, s32 type) { + s32 i; + s32 choice_num; + f32 x; + f32 y; + s32 selected_idx; + + x = choice->textX; + y = choice->textY; + choice_num = choice->data.choiceNum; + selected_idx = choice->selectedChoiceIdx; + + for (i = 0; i < choice_num; i++) { + s32 r; + s32 g; + s32 b; + if (i == selected_idx) { + r = choice->selectedChoiceTextColor.r; + g = choice->selectedChoiceTextColor.g; + b = choice->selectedChoiceTextColor.b; + mFont_SetMarkChar(game, 4, x - 16.0f, y, choice->backgroundColor.r, choice->backgroundColor.g, + choice->backgroundColor.b, 255, FALSE, 1.0f, 1.0f, type); + } else { + r = choice->textColor.r; + g = choice->textColor.g; + b = choice->textColor.b; + } + + mFont_SetLineStrings_AndSpace(game, choice->data.strings[i], choice->data.stringLens[i], x, y, r, g, b, 255, + FALSE, FALSE, 0, 1.0f, 1.0f, type); + + y += 16.0f; + } +} + +void mChoice_Draw(Choice* choice, Game* game, s32 mode) { + if (choice->isWindowVisible) { + mFont_SetMatrix(game->gfxCtx, mode); + mChoice_SetMatrix(choice, game, mode); + mChoice_SetMatrixDisplay(choice, game, mode); + mChoice_DrawWindowBody(choice, game, mode); + mChoice_UnSetMatrixDisplay(game, mode); + mChoice_DrawFont(choice, game, mode); + mChoice_UnSetMatrix(); + mFont_UnSetMatrix(game->gfxCtx, mode); + } +} + +void mChoice_ct(Choice* choice, Game* game) { + mChoice_check_ct(choice, game); + mChoice_init(choice, game); +} + +void mChoice_dt(UNUSED Choice* choice, UNUSED Game* game) { +} diff --git a/yamls/jp/code.yaml b/yamls/jp/code.yaml index 13fd372..5dfc938 100644 --- a/yamls/jp/code.yaml +++ b/yamls/jp/code.yaml @@ -16,7 +16,7 @@ - [0x67D890, asm, code/67D890] - [0x67E840, asm, code/67E840] - [0x683030, asm, code/683030] - - [0x688CE0, asm, code/m_choice_main] + - [0x688CE0, c, code/m_choice_main] - [0x68AAF0, c, code/m_clip] - [0x68AB30, c, code/m_cockroach] - [0x68B0D0, asm, code/m_collision_bg] @@ -145,6 +145,14 @@ - [0x724930, .data, code/m_actor_dlftbls] - [0x726260, .data, code/m_actor_shadow] - [0x7262C0, data, code/7262C0] + - start: 0x726720 + type: .data + name: code/m_choice_main + subsegments: + - [0x726720] + - [0x7268C8, vtx, code/m_choice_main/con_sentaku2_v] + - [0x726908, i4, code/m_choice_main/con_waku_swaku3_tex, 128, 64] + - [0x727908] - [0x7279F0, data, code/7279F0] - [0x728340, .data, code/m_collision_obj] - [0x728430, data, code/69CB30] @@ -199,7 +207,7 @@ - [0x739F20, rodata, code/739F20] - [0x739F70, rodata, code/739F70] - [0x739FA0, rodata, code/739FA0] - - [0x73A080, rodata, code/73A080] + - [0x73A080, .rodata, code/m_choice_main] - [0x73A0F0, rodata, code/73A0F0] - [0x73A480, .rodata, code/m_collision_obj] - [0x73A490, .rodata, code/m_controller] |
