diff --git a/config/dol.yml b/config/dol.yml index 520a2a3c..f6f55442 100644 --- a/config/dol.yml +++ b/config/dol.yml @@ -21,4 +21,5 @@ section_defs: bss: - name: .bss balign: 4 - - name: .sbss \ No newline at end of file + - name: .sbss +label_prefix: ".L" \ No newline at end of file diff --git a/config/rel.yml b/config/rel.yml index 8c9825af..4edb6246 100644 --- a/config/rel.yml +++ b/config/rel.yml @@ -1,4 +1,5 @@ path: dump/foresta.rel address: 0x803701C0 bss_address: 0x8125A7C0 -dol: config/dol.yml \ No newline at end of file +dol: config/dol.yml +label_prefix: ".L" \ No newline at end of file diff --git a/include/Famicom/famicom.h b/include/Famicom/famicom.h index 34340e29..4ce4c198 100644 --- a/include/Famicom/famicom.h +++ b/include/Famicom/famicom.h @@ -21,7 +21,7 @@ extern "C" { #define NESTAG_GID "GID" #define NESTAG_GNM "GNM" #define NESTAG_CPN "CPN" -#define NESTAG_OFS "OFS" /* Offset into the shared highscore data to read/write at */ +#define NESTAG_OFS "OFS" /* Offset into the shared highscore data to read/write at */ #define NESTAG_HSC "HSC" #define NESTAG_GNO "GNO" #define NESTAG_BBR "BBR" @@ -47,122 +47,122 @@ typedef void* (*MALLOC_ALIGN_FUNC)(size_t size, u32 align); typedef void (*MALLOC_FREE_FUNC)(void* ptr); typedef int (*MALLOC_GETMEMBLOCKSIZE_FUNC)(void* ptr); typedef int (*MALLOC_GETTOTALFREESIZE_FUNC)(); - + typedef struct malloc_s { - MALLOC_ALIGN_FUNC malloc_align; - MALLOC_FREE_FUNC free; - MALLOC_GETMEMBLOCKSIZE_FUNC getmemblocksize; - MALLOC_GETTOTALFREESIZE_FUNC gettotalfreesize; + MALLOC_ALIGN_FUNC malloc_align; + MALLOC_FREE_FUNC free; + MALLOC_GETMEMBLOCKSIZE_FUNC getmemblocksize; + MALLOC_GETTOTALFREESIZE_FUNC gettotalfreesize; } Famicom_MallocInfo; enum filer_demo_mode { - FILER_DEMO_MODE_NORMAL, - FILER_DEMO_MODE_AUTO, + FILER_DEMO_MODE_NORMAL, + FILER_DEMO_MODE_AUTO, - FILER_DEMO_MODE_NUM + FILER_DEMO_MODE_NUM }; #define FAMICOM_SAVE_DATA_NAME_LEN 8 +#define FAMICOM_MORI_NAME_LEN 16 typedef struct FamicomSaveDataHeader { - u8 name[FAMICOM_SAVE_DATA_NAME_LEN]; - u8 _08; - u8 _09; - u8 headerSize; - u8 checksum; - u16 size; - u8 no_save; - u8 _temp[FAMICOM_SAVE_HEADER_SIZE - 0x000F]; + u8 name[FAMICOM_SAVE_DATA_NAME_LEN]; + u8 _08; + u8 _09; + u8 headerSize; + u8 checksum; + u16 size; + u8 no_save; + u8 _temp[FAMICOM_SAVE_HEADER_SIZE - 0x000F]; } FamicomSaveDataHeader; enum { - MEMCARD_COMMENT_TYPE_NONE, - MEMCARD_COMMENT_TYPE_DEFAULT, - MEMCARD_COMMENT_TYPE_COPY_ROM, // converts rom's comment but converts "] ROM" to "] SAVE" - MEMCARD_COMMENT_TYPE_COPY_EMBEDDED // uses the embedded and unique 'save' comment + MEMCARD_COMMENT_TYPE_NONE, + MEMCARD_COMMENT_TYPE_DEFAULT, + MEMCARD_COMMENT_TYPE_COPY_ROM, // converts rom's comment but converts "] ROM" to "] SAVE" + MEMCARD_COMMENT_TYPE_COPY_EMBEDDED // uses the embedded and unique 'save' comment }; enum { - MEMCARD_BANNER_TYPE_NONE, - MEMCARD_BANNER_TYPE_DEFAULT, - MEMCARD_BANNER_TYPE_COPY_ROM, // copies the NES rom save's banner - MEMCARD_BANNER_TYPE_COPY_EMBEDDED // uses the embedded and unique 'save' banner + MEMCARD_BANNER_TYPE_NONE, + MEMCARD_BANNER_TYPE_DEFAULT, + MEMCARD_BANNER_TYPE_COPY_ROM, // copies the NES rom save's banner + MEMCARD_BANNER_TYPE_COPY_EMBEDDED // uses the embedded and unique 'save' banner }; enum { - MEMCARD_ICON_TYPE_NONE, - MEMCARD_ICON_TYPE_DEFAULT, - MEMCARD_ICON_TYPE_COPY_ROM, // copies the NES rom save's icon - MEMCARD_ICON_TYPE_COPY_EMBEDDED // uses the embedded and unique 'save' icon + MEMCARD_ICON_TYPE_NONE, + MEMCARD_ICON_TYPE_DEFAULT, + MEMCARD_ICON_TYPE_COPY_ROM, // copies the NES rom save's icon + MEMCARD_ICON_TYPE_COPY_EMBEDDED // uses the embedded and unique 'save' icon }; enum { - FAMICOM_RESULT_OK, - FAMICOM_RESULT_NOSPACE, - FAMICOM_RESULT_NOENTRY, - FAMICOM_RESULT_BROKEN, - FAMICOM_RESULT_WRONGDEVICE, - FAMICOM_RESULT_WRONGENCODING, - FAMICOM_RESULT_NOCARD, - FAMICOM_RESULT_NOFILE + FAMICOM_RESULT_OK, + FAMICOM_RESULT_NOSPACE, + FAMICOM_RESULT_NOENTRY, + FAMICOM_RESULT_BROKEN, + FAMICOM_RESULT_WRONGDEVICE, + FAMICOM_RESULT_WRONGENCODING, + FAMICOM_RESULT_NOCARD, + FAMICOM_RESULT_NOFILE }; typedef struct MemcardGameHeader_t { - u8 _00; - u8 _01; - u8 mori_name[16]; - u16 nesrom_size; - u16 nestags_size; - u16 icon_format; - u16 icon_flags; - u16 comment_img_size; /* Size of comment + banner + icon */ - struct { - u8 has_comment_img:1; - u8 comment_type:2; - u8 banner_type:2; - u8 icon_type:2; - u8 no_copy_flag:1; - } flags0; - struct { - u8 no_move_flag:1; - u8 banner_fmt:2; - u8 reserved:5; - } flags1; - u16 pad; + u8 _00; + u8 _01; + u8 mori_name[FAMICOM_MORI_NAME_LEN]; + u16 nesrom_size; + u16 nestags_size; + u16 icon_format; + u16 icon_flags; + u16 comment_img_size; /* Size of comment + banner + icon */ + struct { + u8 has_comment_img : 1; + u8 comment_type : 2; + u8 banner_type : 2; + u8 icon_type : 2; + u8 no_copy_flag : 1; + } flags0; + struct { + u8 no_move_flag : 1; + u8 banner_fmt : 2; + u8 reserved : 5; + } flags1; + u16 pad; } MemcardGameHeader_t; /* sizeof (FamicomCommon) == 0xB8 */ typedef struct FamicomCommon { - /* 0x00 */ ksNesCommonWorkObj* wp; - /* 0x04 */ ksNesStateObj* sp; - /* 0x08 */ u8* nesromp; - /* 0x0C */ u8* chrramp; - /* 0x10 */ u8* bbramp; - /* 0x14 */ u8* noise_bufp; - /* 0x18 */ u8* chr_to_i8_bufp; - /* 0x1C */ u8* result_bufp; - /* 0x20 */ u8* highscore_flagsp; - /* 0x24 */ u8* nesinfo_tagsp; - /* 0x28 */ int _28; - /* 0x2C */ u8 nesrom_memcard; // TRUE: rom is loaded from memcard, FALSE: rom is loaded internally - /* 0x2D */ u8 rom_no; - /* 0x2E */ s8 save_pl_no; - /* 0x2F */ u8 mura_save_name[33]; - /* 0x50 */ u8 famicom_save_name[33]; - /* 0x74 */ FamicomSaveDataHeader* save_data_header; - /* 0x78 */ u8* internal_save_datap; - /* 0x7C */ size_t save_data_total_size; - /* 0x80 */ size_t save_data_single_size; - /* 0x84 */ int _84; - /* 0x88 */ u8* save_data_name; - /* 0x8C */ u8 _8C; - /* 0x8D */ u8 low_res_mode; - /* 0x8E */ MemcardGameHeader_t memcard_game_header; - /* 0xB0 */ u8* memcard_save_comment; - /* 0xB4 */ size_t unused_save_data_start_ofs; + /* 0x00 */ ksNesCommonWorkObj* wp; + /* 0x04 */ ksNesStateObj* sp; + /* 0x08 */ u8* nesromp; + /* 0x0C */ u8* chrramp; + /* 0x10 */ u8* bbramp; + /* 0x14 */ u8* noise_bufp; + /* 0x18 */ u8* chr_to_i8_bufp; + /* 0x1C */ u8* result_bufp; + /* 0x20 */ u8* highscore_flagsp; + /* 0x24 */ u8* nesinfo_tagsp; + /* 0x28 */ int _28; + /* 0x2C */ u8 nesrom_memcard; // TRUE: rom is loaded from memcard, FALSE: rom is loaded internally + /* 0x2D */ u8 rom_no; + /* 0x2E */ s8 save_pl_no; + /* 0x2F */ u8 mura_save_name[33]; + /* 0x50 */ u8 famicom_save_name[33]; + /* 0x74 */ FamicomSaveDataHeader* save_data_header; + /* 0x78 */ u8* internal_save_datap; + /* 0x7C */ size_t save_data_total_size; + /* 0x80 */ size_t save_data_single_size; + /* 0x84 */ int _84; + /* 0x88 */ u8* save_data_name; + /* 0x8C */ u8 _8C; + /* 0x8D */ u8 low_res_mode; + /* 0x8E */ MemcardGameHeader_t memcard_game_header; + /* 0xB0 */ u8* memcard_save_comment; + /* 0xB4 */ size_t unused_save_data_start_ofs; } FamicomCommon; - extern Famicom_MallocInfo* my_malloc_current; extern u8 save_game_image; extern u8** nesrom_filename_ptrs; @@ -213,7 +213,6 @@ extern u8* nesinfo_get_moriName(); extern void nesinfo_init(); extern void highscore_setup_flags(u8* flags); - #ifdef __cplusplus } #endif diff --git a/include/ac_furniture.h b/include/ac_furniture.h index 0ffbc750..254479c8 100644 --- a/include/ac_furniture.h +++ b/include/ac_furniture.h @@ -220,7 +220,7 @@ struct furniture_actor_s { f32 dynamic_work_f[2]; /* reserved for any use by each unique furniture actor */ s16 layer; /* layer the furniture actor resides on */ s16 _83E; - s16 open_music_disk; /* set when a music player is interacted with */ + s16 demo_status; /* set when a music player is interacted with */ s16 dust_timer; mActor_name_t items[aFTR_KEEP_ITEM_COUNT]; /* used for holding items (music players & wardrobes) */ int _84C; diff --git a/include/audio_defs.h b/include/audio_defs.h index 18859c04..2ff8f2d4 100644 --- a/include/audio_defs.h +++ b/include/audio_defs.h @@ -15,12 +15,12 @@ extern "C" { #define MONO(id) (id | 0x1000) #define SE_FLAG_15(id) (id | 0x8000) -//TODO: Make the rest of Sound Effects with parameters +// TODO: Make the rest of Sound Effects with parameters #define SE_REGISTER MONO(0x50) -typedef enum audio_sound_effects{ +typedef enum audio_sound_effects { NA_SE_START, - NA_SE_CURSOL, + NA_SE_CURSOL, NA_SE_MENU_EXIT, NA_SE_ZOOMUP = 4, @@ -109,14 +109,19 @@ typedef enum audio_sound_effects{ NA_SE_KARABURI = 0x43A, NA_SE_ROD_STROKE_SMALL = 0x445, - + NA_SE_SCOOP_TREE_HIT = 0x448, NA_SE_SCOOP_ITEM_HIT, NA_SE_AXE_BALL_HIT, NA_SE_COIN_GASAGOSO = 0x465, -}AudioSE; +} AudioSE; + +typedef enum bgm_e { + BGM_MD0 = 128, + +} BGM_e; #ifdef __cplusplus } diff --git a/include/famicom_emu.h b/include/famicom_emu.h index b260dd60..c797ba43 100644 --- a/include/famicom_emu.h +++ b/include/famicom_emu.h @@ -11,7 +11,7 @@ extern "C" { /* sizeof(struct game_famicom_emu_s) == 0xE0 */ typedef struct game_famicom_emu_s { - /* 0x00 */ GAME game; + /* 0x00 */ GAME game; } GAME_FAMICOM_EMU; extern Famicom_MallocInfo my_malloc_func; @@ -19,8 +19,8 @@ extern Famicom_MallocInfo my_malloc_func; extern void famicom_emu_main(GAME* game); extern void famicom_emu_init(GAME* game); extern void famicom_emu_cleanup(GAME* game); -extern int famicom_gba_getImage(u32 rom_id, int* ptr); -extern void famicom_gba_removeImage(void* ); +extern void* famicom_gba_getImage(u32 rom_id, size_t* size); +extern void famicom_gba_removeImage(void*); #ifdef __cplusplus } diff --git a/include/libjsys/jsyswrapper.h b/include/libjsys/jsyswrapper.h index c1938f10..e93f8bdb 100644 --- a/include/libjsys/jsyswrapper.h +++ b/include/libjsys/jsyswrapper.h @@ -12,12 +12,12 @@ extern "C" { #endif typedef struct { - u16 mFileID; // _00 - u16 mHash; // _02 - u32 mFlag; // _04 - u32 mDataOffset; // _08 - u32 mSize; // _0C - void* mData; // _10 + u16 mFileID; // _00 + u16 mHash; // _02 + u32 mFlag; // _04 + u32 mDataOffset; // _08 + u32 mSize; // _0C + void* mData; // _10 } CSDIFileEntry; extern void* JC_JFWSystem_getSystemConsole(); @@ -116,8 +116,8 @@ extern void* JC_JUTFader_new(int ul_x, int ul_y, int br_x, int br_y, u32* color) extern void JC_JUTFader_delete(void* fader); extern void JC_JFWDisplay_changeToDoubleXfb(void* manager); -extern u32 JC__JKRGetResource(char* resourceName); -extern int JC__JKRGetMemBlockSize(int, u32); +extern void* JC__JKRGetResource(const char* resourceName); +extern u32 JC__JKRGetMemBlockSize(int, void*); extern void JC__JKRRemoveResource(void* res); diff --git a/include/m_choice.h b/include/m_choice.h index 3d29970c..bb496e99 100644 --- a/include/m_choice.h +++ b/include/m_choice.h @@ -15,94 +15,94 @@ typedef struct choice_s mChoice_c; typedef struct choice_data_s mChoice_Data_c; enum choice { - mChoice_CHOICE0, - mChoice_CHOICE1, - mChoice_CHOICE2, - mChoice_CHOICE3, - mChoice_CHOICE4, - mChoice_CHOICE5, + mChoice_CHOICE0, + mChoice_CHOICE1, + mChoice_CHOICE2, + mChoice_CHOICE3, + mChoice_CHOICE4, + mChoice_CHOICE5, - mChoice_CHOICE_NUM + mChoice_CHOICE_NUM }; enum { - mChoice_AUTOMOVE_STOPPED, - mChoice_AUTOMOVE_INCREMENT_WAIT, - mChoice_AUTOMOVE_INCREMENT, - mChoice_AUTOMOVE_DECREMENT_WAIT, - mChoice_AUTOMOVE_DECREMENT, + mChoice_AUTOMOVE_STOPPED, + mChoice_AUTOMOVE_INCREMENT_WAIT, + mChoice_AUTOMOVE_INCREMENT, + mChoice_AUTOMOVE_DECREMENT_WAIT, + mChoice_AUTOMOVE_DECREMENT, - mChoice_AUTOMOVE_NUM + mChoice_AUTOMOVE_NUM }; enum { - mChoice_MAIN_HIDE, - mChoice_MAIN_APPEAR, - mChoice_MAIN_NORMAL, - mChoice_MAIN_DISAPPEAR, + mChoice_MAIN_HIDE, + mChoice_MAIN_APPEAR, + mChoice_MAIN_NORMAL, + mChoice_MAIN_DISAPPEAR, - mChoice_MAIN_INDEX_NUM + mChoice_MAIN_INDEX_NUM }; struct choice_data_s { - u8 strings[mChoice_CHOICE_NUM][mChoice_CHOICE_STRING_LEN]; - int string_lens[mChoice_CHOICE_NUM]; - u8 determination_string[mChoice_CHOICE_STRING_LEN]; - int determination_len; - int choice_num; - int selected_choice_idx; + u8 strings[mChoice_CHOICE_NUM][mChoice_CHOICE_STRING_LEN]; + int string_lens[mChoice_CHOICE_NUM]; + u8 determination_string[mChoice_CHOICE_STRING_LEN]; + int determination_len; + int choice_num; + int selected_choice_idx; }; struct choice_s { - /* Current XY position (centered) */ - /* 0x00 */ f32 center_x; - /* 0x04 */ f32 center_y; + /* Current XY position (centered) */ + /* 0x00 */ f32 center_x; + /* 0x04 */ f32 center_y; - /* Initial XY position */ - /* 0x08 */ f32 center_x_begin; - /* 0x0C */ f32 center_y_begin; + /* Initial XY position */ + /* 0x08 */ f32 center_x_begin; + /* 0x0C */ f32 center_y_begin; - /* Target XY position */ - /* 0x10 */ f32 center_x_target; - /* 0x14 */ f32 center_y_target; + /* Target XY position */ + /* 0x10 */ f32 center_x_target; + /* 0x14 */ f32 center_y_target; - /* Text settings */ - /* 0x18 */ rgba_t text_color; - /* 0x1C */ f32 text_scale_x; - /* 0x20 */ f32 text_scale_y; - /* 0x24 */ f32 text_x; - /* 0x28 */ f32 text_y; + /* Text settings */ + /* 0x18 */ rgba_t text_color; + /* 0x1C */ f32 text_scale_x; + /* 0x20 */ f32 text_scale_y; + /* 0x24 */ f32 text_x; + /* 0x28 */ f32 text_y; - /* Window scaling XY */ - /* 0x2C */ f32 scale_x; - /* 0x30 */ f32 scale_y; + /* Window scaling XY */ + /* 0x2C */ f32 scale_x; + /* 0x30 */ f32 scale_y; - /* Text related data */ - /* 0x34 */ mChoice_Data_c data; + /* Text related data */ + /* 0x34 */ mChoice_Data_c data; - /* 0xC8 */ int selected_choice_idx; - /* 0xCC */ rgba_t selected_choice_text_color; - - /* 0xD0 */ rgba_t background_color; + /* 0xC8 */ int selected_choice_idx; + /* 0xCC */ rgba_t selected_choice_text_color; - /* 0xD4 */ f32 _D4; - /* 0xD8 */ f32 _D8; + /* 0xD0 */ rgba_t background_color; - /* 0xDC */ f32 scale; // total choice window scaling percentage + /* 0xD4 */ f32 _D4; + /* 0xD8 */ f32 _D8; - /* 0xE0 */ int main_index; - /* 0xE4 */ int requested_main_index; + /* 0xDC */ f32 scale; // total choice window scaling percentage - /* 0xE8 */ int window_visible_flag; - /* 0xEC */ int font_visible_flag; + /* 0xE0 */ int main_index; + /* 0xE4 */ int requested_main_index; - /* 0xF0 */ int choice_automove_type; - /* 0xF4 */ f32 choice_automove_timer; + /* 0xE8 */ int window_visible_flag; + /* 0xEC */ int font_visible_flag; - /* 0xF8 */ f32 timer; + /* 0xF0 */ int choice_automove_type; + /* 0xF4 */ f32 choice_automove_timer; - /* 0xFC */ u8 no_b_flag; // can't press B to select last option - /* 0xFD */ u8 no_close_flag; // pressing B won't auto-cancel the choice selection? + /* 0xF8 */ f32 timer; + + /* 0xFC */ u8 no_b_flag; // can't press B to select last option + /* 0xFD */ u8 no_close_flag; // pressing B won't auto-cancel the choice selection? }; extern void mChoice_Main(mChoice_c* choice, GAME* game); @@ -114,13 +114,21 @@ extern mChoice_c* mChoice_Get_base_window_p(); extern void mChoice_Change_request_main_index(mChoice_c* choice, int request_main_index); extern int mChoice_check_main_index(mChoice_c* choice); extern int mChoice_check_main_normal(mChoice_c* choice); -extern void mChoice_Set_choice_data( mChoice_c* choice, u8* str0, int str0_len, u8* str1, int str1_len, u8* str2, int str2_len, u8* str3, int str3_len, u8* str4, int str4_len, u8* str5, int str5_len); +extern void mChoice_Set_choice_data(mChoice_c* choice, u8* str0, int str0_len, u8* str1, int str1_len, u8* str2, + int str2_len, u8* str3, int str3_len, u8* str4, int str4_len, u8* str5, + int str5_len); extern int mChoice_Get_ChoseNum(mChoice_c* choice); extern void mChoice_Clear_ChoseNum(mChoice_c* choice); extern void mChoice_Load_ChoseStringFromRom(mChoice_c* choice, u8* str, int str_no, ACTOR* actor); extern void mChoice_no_b_set(mChoice_c* choice); extern void mChoice_no_b_close_set(mChoice_c* choice); +/* Macros */ +#define mChoice_GET_CHOSENUM() mChoice_Get_ChoseNum(mChoice_Get_base_window_p()) +#define mChoice_CLEAR_CHOSENUM() mChoice_Clear_ChoseNum(mChoice_Get_base_window_p()) +#define mChoice_NO_B_SET() mChoice_no_b_set(mChoice_Get_base_window_p()) +#define mChoice_NO_B_CLOSE_SET() mChoice_no_b_close_set(mChoice_Get_base_window_p()) + #ifdef __cplusplus } #endif diff --git a/include/m_common_data.h b/include/m_common_data.h index 056c7562..672eeea5 100644 --- a/include/m_common_data.h +++ b/include/m_common_data.h @@ -341,6 +341,8 @@ extern common_data_t common_data; #define Player_Palette_Get(idx) (Common_Get(now_private->my_org[idx].palette)) #define Player_Design_Get(idx) (Common_GetPointer(now_private->my_org[idx].design)) +#define Now_Private (Common_Get(now_private)) + #define Able_Sisters_Palette_Get(idx) (Save_Get(needlework.original_design[idx].palette)) #define Able_Sisters_Design_Get(idx) (Save_GetPointer(needlework.original_design[idx].design)) #define Able_Sisters_Cloth_Palette_Get(idx) (Able_Sisters_Palette_Get(idx)) diff --git a/include/m_msg.h b/include/m_msg.h index 27912907..0a87615a 100644 --- a/include/m_msg.h +++ b/include/m_msg.h @@ -21,86 +21,86 @@ extern "C" { #define mMsg_BUTTON_TURN_TIME 60.0f enum { - mMsg_INDEX_HIDE, - mMsg_INDEX_APPEAR, - mMsg_INDEX_NORMAL, - mMsg_INDEX_CURSOL, - mMsg_INDEX_DISAPPEAR, - mMsg_INDEX_APPEAR_WAIT, - mMsg_INDEX_WAIT, - mMsg_INDEX_DISAPPEAR_WAIT, + mMsg_INDEX_HIDE, + mMsg_INDEX_APPEAR, + mMsg_INDEX_NORMAL, + mMsg_INDEX_CURSOL, + mMsg_INDEX_DISAPPEAR, + mMsg_INDEX_APPEAR_WAIT, + mMsg_INDEX_WAIT, + mMsg_INDEX_DISAPPEAR_WAIT, - mMsg_INDEX_NUM + mMsg_INDEX_NUM }; enum { - mMsg_FREE_STR0, - mMsg_FREE_STR1, - mMsg_FREE_STR2, - mMsg_FREE_STR3, - mMsg_FREE_STR4, - mMsg_FREE_STR5, - mMsg_FREE_STR6, - mMsg_FREE_STR7, - mMsg_FREE_STR8, - mMsg_FREE_STR9, - mMsg_FREE_STR10, - mMsg_FREE_STR11, - mMsg_FREE_STR12, - mMsg_FREE_STR13, - mMsg_FREE_STR14, - mMsg_FREE_STR15, - mMsg_FREE_STR16, - mMsg_FREE_STR17, - mMsg_FREE_STR18, - mMsg_FREE_STR19, + mMsg_FREE_STR0, + mMsg_FREE_STR1, + mMsg_FREE_STR2, + mMsg_FREE_STR3, + mMsg_FREE_STR4, + mMsg_FREE_STR5, + mMsg_FREE_STR6, + mMsg_FREE_STR7, + mMsg_FREE_STR8, + mMsg_FREE_STR9, + mMsg_FREE_STR10, + mMsg_FREE_STR11, + mMsg_FREE_STR12, + mMsg_FREE_STR13, + mMsg_FREE_STR14, + mMsg_FREE_STR15, + mMsg_FREE_STR16, + mMsg_FREE_STR17, + mMsg_FREE_STR18, + mMsg_FREE_STR19, - mMsg_FREE_STR_NUM + mMsg_FREE_STR_NUM }; enum { - mMsg_ITEM_STR0, - mMsg_ITEM_STR1, - mMsg_ITEM_STR2, - mMsg_ITEM_STR3, - mMsg_ITEM_STR4, + mMsg_ITEM_STR0, + mMsg_ITEM_STR1, + mMsg_ITEM_STR2, + mMsg_ITEM_STR3, + mMsg_ITEM_STR4, - mMsg_ITEM_STR_NUM + mMsg_ITEM_STR_NUM }; enum { - mMsg_MAIL_STR0, + mMsg_MAIL_STR0, - mMsg_MAIL_STR_NUM + mMsg_MAIL_STR_NUM }; enum { - mMsg_RESULT_VOID, - mMsg_RESULT_FALSE, - mMsg_RESULT_TRUE, + mMsg_RESULT_VOID, + mMsg_RESULT_FALSE, + mMsg_RESULT_TRUE, - mMsg_RESULT_NUM + mMsg_RESULT_NUM }; -#define mMsg_STATUS_FLAG_SOUND_CUT (1 << 0) // 0x000001 +#define mMsg_STATUS_FLAG_SOUND_CUT (1 << 0) // 0x000001 #define mMsg_STATUS_FLAG_NO_SE_PAGE_OKURI (1 << 1) // 0x000002 -#define mMsg_STATUS_FLAG_NO_ZOOMUP (1 << 2) // 0x000004 -#define mMsg_STATUS_FLAG_LAST_DELAY (1 << 3) // 0x000008 -#define mMsg_STATUS_FLAG_SPEC_VOICE (1 << 4) // 0x000010 -#define mMsg_STATUS_FLAG_VOICE_ENTRY (1 << 5) // 0x000020 -#define mMsg_STATUS_FLAG_IDLING_REQ (1 << 6) // 0x000040 -#define mMsg_STATUS_FLAG_IDLING_NOW (1 << 7) // 0x000080 -#define mMsg_STATUS_FLAG_FAST_TEXT (1 << 8) // 0x000100 -#define mMsg_STATUS_FLAG_NOT_PAUSE_FRAME (1 << 9) // 0x000200 -#define mMsg_STATUS_FLAG_UTTER (1 << 10) // 0x000400 -#define mMsg_STATUS_FLAG_NO_ZOOMDOWN (1 << 11) /* When set, mMsg_sound_ZOOMDOWN_[SHORT, LONG]() sfx will not play */ -#define mMsg_STATUS_FLAG_VOICE_CLICK (1 << 12) // 0x001000 -#define mMsg_STATUS_FLAG_VOICE_SILENT (1 << 13) // 0x002000 -#define mMsg_STATUS_FLAG_CURSOL_JUST (1 << 14) /* Sets cursor justification */ -#define mMsg_STATUS_FLAG_CUT_ARTICLE (1 << 15) // 0x008000 -#define mMsg_STATUS_FLAG_CAPITALIZE (1 << 16) // 0x010000 -#define mMsg_STATUS_FLAG_USE_AM (1 << 17) /* 'AM' when set, 'PM' when not set */ -#define mMsg_STATUS_FLAG_18 (1 << 18) // 0x040000 +#define mMsg_STATUS_FLAG_NO_ZOOMUP (1 << 2) // 0x000004 +#define mMsg_STATUS_FLAG_LAST_DELAY (1 << 3) // 0x000008 +#define mMsg_STATUS_FLAG_SPEC_VOICE (1 << 4) // 0x000010 +#define mMsg_STATUS_FLAG_VOICE_ENTRY (1 << 5) // 0x000020 +#define mMsg_STATUS_FLAG_IDLING_REQ (1 << 6) // 0x000040 +#define mMsg_STATUS_FLAG_IDLING_NOW (1 << 7) // 0x000080 +#define mMsg_STATUS_FLAG_FAST_TEXT (1 << 8) // 0x000100 +#define mMsg_STATUS_FLAG_NOT_PAUSE_FRAME (1 << 9) // 0x000200 +#define mMsg_STATUS_FLAG_UTTER (1 << 10) // 0x000400 +#define mMsg_STATUS_FLAG_NO_ZOOMDOWN (1 << 11) /* When set, mMsg_sound_ZOOMDOWN_[SHORT, LONG]() sfx will not play */ +#define mMsg_STATUS_FLAG_VOICE_CLICK (1 << 12) // 0x001000 +#define mMsg_STATUS_FLAG_VOICE_SILENT (1 << 13) // 0x002000 +#define mMsg_STATUS_FLAG_CURSOL_JUST (1 << 14) /* Sets cursor justification */ +#define mMsg_STATUS_FLAG_CUT_ARTICLE (1 << 15) // 0x008000 +#define mMsg_STATUS_FLAG_CAPITALIZE (1 << 16) // 0x010000 +#define mMsg_STATUS_FLAG_USE_AM (1 << 17) /* 'AM' when set, 'PM' when not set */ +#define mMsg_STATUS_FLAG_18 (1 << 18) // 0x040000 typedef struct message_window_s mMsg_Window_c; typedef struct message_data_s mMsg_Data_c; @@ -108,160 +108,160 @@ typedef struct message_data_s mMsg_Data_c; /* These are hinted at due to the 8-byte alignment forced onto these structs */ typedef struct { - int saved_main_index; + int saved_main_index; } mMsg_MainAppearWait_Data_c; typedef struct { - int saved_main_index; + int saved_main_index; } mMsg_MainDisappearWait_Data_c; typedef struct { - int last_main_index; + int last_main_index; } mMsg_MainWait_Data_c; typedef union { - mMsg_MainAppearWait_Data_c main_appear_wait; - mMsg_MainDisappearWait_Data_c main_disappear_wait; - mMsg_MainWait_Data_c main_wait; - u64 align; + mMsg_MainAppearWait_Data_c main_appear_wait; + mMsg_MainDisappearWait_Data_c main_disappear_wait; + mMsg_MainWait_Data_c main_wait; + u64 align; } mMsg_Main_Data_c; typedef struct { - ACTOR* speaker_actor; - int msg_no; - int name_shown_flag; - rgba_t window_color; + ACTOR* speaker_actor; + int msg_no; + int name_shown_flag; + rgba_t window_color; } mMsg_Request_MainAppear_Data_c; typedef struct { - int last_main_index; - u32 setup_flag; + int last_main_index; + u32 setup_flag; } mMsg_Request_MainAppearWait_Data_c; typedef struct { - int wait_flag; + int wait_flag; } mMsg_Request_MainCursor_Data_c; typedef struct { - int last_main_index; + int last_main_index; } mMsg_Request_MainDisappearWait_Data_c; typedef struct { - int wait_flag; + int wait_flag; } mMsg_Request_MainNormal_Data_c; typedef struct { - int last_main_index; + int last_main_index; } mMsg_Request_MainWait_Data_c; typedef union { - mMsg_Request_MainAppear_Data_c request_main_appear; - mMsg_Request_MainAppearWait_Data_c request_main_appear_wait; - mMsg_Request_MainCursor_Data_c request_main_cursor; - mMsg_Request_MainDisappearWait_Data_c request_main_disappear_wait; - mMsg_Request_MainNormal_Data_c request_main_normal; - mMsg_Request_MainWait_Data_c request_main_wait; - u64 align; + mMsg_Request_MainAppear_Data_c request_main_appear; + mMsg_Request_MainAppearWait_Data_c request_main_appear_wait; + mMsg_Request_MainCursor_Data_c request_main_cursor; + mMsg_Request_MainDisappearWait_Data_c request_main_disappear_wait; + mMsg_Request_MainNormal_Data_c request_main_normal; + mMsg_Request_MainWait_Data_c request_main_wait; + u64 align; } mMsg_Request_Data_c; typedef union { - u8 data[mMsg_MSG_BUF_SIZE] ATTRIBUTE_ALIGN(32); - u64 align; + u8 data[mMsg_MSG_BUF_SIZE] ATTRIBUTE_ALIGN(32); + u64 align; } mMsg_MsgBuf_c; struct message_data_s { - int data_loaded; - int msg_no; - int msg_len; - int cut; + int data_loaded; + int msg_no; + int msg_len; + int cut; - mMsg_MsgBuf_c text_buf; + mMsg_MsgBuf_c text_buf; }; struct message_window_s { - /* 0x000 */ int data_loaded; - /* 0x004 */ int msg_no; - /* 0x008 */ int _008; - /* 0x00C */ mMsg_Data_c* msg_data; - /* 0x010 */ f32 center_x; - /* 0x014 */ f32 center_y; - /* 0x018 */ f32 width; - /* 0x01C */ f32 height; - - /* 0x020 */ ACTOR* client_actor_p; - /* 0x024 */ int show_actor_name; - /* 0x028 */ int client_name_len; - /* 0x02C */ f32 nameplate_x; - /* 0x030 */ f32 nameplate_y; + /* 0x000 */ int data_loaded; + /* 0x004 */ int msg_no; + /* 0x008 */ int _008; + /* 0x00C */ mMsg_Data_c* msg_data; + /* 0x010 */ f32 center_x; + /* 0x014 */ f32 center_y; + /* 0x018 */ f32 width; + /* 0x01C */ f32 height; - /* 0x034 */ int show_continue_button; + /* 0x020 */ ACTOR* client_actor_p; + /* 0x024 */ int show_actor_name; + /* 0x028 */ int client_name_len; + /* 0x02C */ f32 nameplate_x; + /* 0x030 */ f32 nameplate_y; - /* 0x038 */ u8 free_str[mMsg_FREE_STR_NUM][mMsg_FREE_STRING_LEN]; - /* 0x178 */ int free_str_article[mMsg_FREE_STR_NUM]; + /* 0x034 */ int show_continue_button; - /* 0x1C8 */ u8 item_str[mMsg_ITEM_STR_NUM][mIN_ITEM_NAME_LEN]; - /* 0x218 */ int item_str_article[mMsg_ITEM_STR_NUM]; + /* 0x038 */ u8 free_str[mMsg_FREE_STR_NUM][mMsg_FREE_STRING_LEN]; + /* 0x178 */ int free_str_article[mMsg_FREE_STR_NUM]; - /* 0x22C */ u8 mail_str[mMsg_MAIL_STR_NUM][mMsg_MAIL_STRING_LEN]; + /* 0x1C8 */ u8 item_str[mMsg_ITEM_STR_NUM][mIN_ITEM_NAME_LEN]; + /* 0x218 */ int item_str_article[mMsg_ITEM_STR_NUM]; - /* 0x2B0 */ rgba_t name_text_color; - /* 0x2B4 */ rgba_t name_background_color; + /* 0x22C */ u8 mail_str[mMsg_MAIL_STR_NUM][mMsg_MAIL_STRING_LEN]; - /* 0x2B8 */ rgba_t window_background_color; - /* 0x2BC */ rgba_t font_color[mMsg_MAX_LINE]; + /* 0x2B0 */ rgba_t name_text_color; + /* 0x2B4 */ rgba_t name_background_color; - /* 0x2CC */ rgba_t continue_button_color; + /* 0x2B8 */ rgba_t window_background_color; + /* 0x2BC */ rgba_t font_color[mMsg_MAX_LINE]; - /* 0x2D0 */ f32 font_scale_x; - /* 0x2D4 */ f32 font_scale_y; + /* 0x2CC */ rgba_t continue_button_color; - /* 0x2D8 */ int _2D8; - /* 0x2DC */ int _2DC; + /* 0x2D0 */ f32 font_scale_x; + /* 0x2D4 */ f32 font_scale_y; - /* 0x2E0 */ int text_lines; - /* 0x2E4 */ int now_display_line; + /* 0x2D8 */ int _2D8; + /* 0x2DC */ int _2DC; - /* 0x2E8 */ mChoice_c choice_window; + /* 0x2E0 */ int text_lines; + /* 0x2E4 */ int now_display_line; - /* 0x3E8 */ int _3E8; + /* 0x2E8 */ mChoice_c choice_window; - /* 0x3EC */ u16 end_timer; - /* 0x3EE */ s16 animal_voice_idx; - /* 0x3F0 */ int voice_sfx_idx; - /* 0x3F4 */ u8 voice_idx; - /* 0x3F5 */ u8 voice2_idx; - /* 0x3F6 */ u8 voice3_idx; - /* 0x3F7 */ s8 hide_choice_window_timer; - /* 0x3F8 */ u8 force_voice_enable_flag; - /* 0x3FC */ int spec; - /* 0x400 */ u8 free_str_color_idx[4]; - /* 0x408 */ u8 _404[8]; // unused? - /* 0x40C */ u32 status_flags; + /* 0x3E8 */ int _3E8; - /* 0x410 */ f32 timer; - /* 0x414 */ f32 cursor_timer; - /* 0x418 */ f32 continue_button_timer; + /* 0x3EC */ u16 end_timer; + /* 0x3EE */ s16 animal_voice_idx; + /* 0x3F0 */ int voice_sfx_idx; + /* 0x3F4 */ u8 voice_idx; + /* 0x3F5 */ u8 voice2_idx; + /* 0x3F6 */ u8 voice3_idx; + /* 0x3F7 */ s8 hide_choice_window_timer; + /* 0x3F8 */ u8 force_voice_enable_flag; + /* 0x3FC */ int spec; + /* 0x400 */ u8 free_str_color_idx[4]; + /* 0x408 */ u8 _404[8]; // unused? + /* 0x40C */ u32 status_flags; - /* 0x41C */ int start_text_cursor_idx; - /* 0x420 */ int end_text_cursor_idx; - /* 0x424 */ f32 window_scale; - /* 0x428 */ f32 text_scale; + /* 0x410 */ f32 timer; + /* 0x414 */ f32 cursor_timer; + /* 0x418 */ f32 continue_button_timer; - /* 0x42C */ int requested_main_index; - /* 0x430 */ int requested_priority; + /* 0x41C */ int start_text_cursor_idx; + /* 0x420 */ int end_text_cursor_idx; + /* 0x424 */ f32 window_scale; + /* 0x428 */ f32 text_scale; - /* 0x434 */ int main_index; - /* 0x438 */ int draw_flag; - /* 0x43C */ int cancel_flag; - /* 0x440 */ int cancelable_flag; - /* 0x444 */ int continue_msg_no; - /* 0x448 */ int continue_cancel_flag; - /* 0x44C */ int force_next; - /* 0x450 */ int lock_continue; - /* 0x454 */ u8 now_utter; + /* 0x42C */ int requested_main_index; + /* 0x430 */ int requested_priority; - /* 0x458 */ mMsg_Main_Data_c main_data; - /* 0x460 */ mMsg_Request_Data_c request_data; + /* 0x434 */ int main_index; + /* 0x438 */ int draw_flag; + /* 0x43C */ int cancel_flag; + /* 0x440 */ int cancelable_flag; + /* 0x444 */ int continue_msg_no; + /* 0x448 */ int continue_cancel_flag; + /* 0x44C */ int force_next; + /* 0x450 */ int lock_continue; + /* 0x454 */ u8 now_utter; + + /* 0x458 */ mMsg_Main_Data_c main_data; + /* 0x460 */ mMsg_Request_Data_c request_data; }; extern void mMsg_aram_init(); @@ -279,7 +279,8 @@ extern int mMsg_Check_not_series_main_wait(mMsg_Window_c* msg_p); extern int mMsg_Check_main_hide(mMsg_Window_c* msg_p); extern int mMsg_request_main_forceoff(); extern int mMsg_request_main_disappear(mMsg_Window_c* msg_p); -extern int mMsg_request_main_appear(mMsg_Window_c* msg_p, ACTOR* client_actor_p, int show_name, rgba_t* window_color, int msg_no, int request_priority); +extern int mMsg_request_main_appear(mMsg_Window_c* msg_p, ACTOR* client_actor_p, int show_name, rgba_t* window_color, + int msg_no, int request_priority); extern int mMsg_request_main_disappear_wait_type1(mMsg_Window_c* msg_p); extern int mMsg_request_main_disappear_wait_type2(mMsg_Window_c* msg_p); extern int mMsg_request_main_appear_wait_type2(mMsg_Window_c* msg_p, int clear_flag); @@ -323,13 +324,15 @@ extern int mMsg_CopyDay(u8* data, int start_idx, int len); extern int mMsg_CopyHour(u8* data, int start_idx, int len); extern int mMsg_CopyMin(u8* data, int start_idx, int len); extern int mMsg_CopySec(u8* data, int start_idx, int len); -extern int mMsg_CopyFree(mMsg_Window_c* msg_p, int str_no, u8* data, int start_idx, int len, int article, u32 capitalize); +extern int mMsg_CopyFree(mMsg_Window_c* msg_p, int str_no, u8* data, int start_idx, int len, int article, + u32 capitalize); extern int mMsg_CopyDetermination(mMsg_Window_c* msg_p, u8* data, int start_idx, int len); -extern int mMsg_CopyCountryName(u8 *data, int start_idx, int len, u32 capitalize); +extern int mMsg_CopyCountryName(u8* data, int start_idx, int len, u32 capitalize); extern int mMsg_CopyIslandName(u8* data, int start_idx, int len, u32 capitalize); extern int mMsg_CopyAmPm(mMsg_Window_c* msg_p, u8* data, int start_idx, int len); extern int mMsg_CopyRamdomNumber2(u8* data, int start_idx, int len); -extern int mMsg_CopyItem(mMsg_Window_c* msg_p, int str_no, u8* data, int start_idx, int len, int article, u32 capitalize); +extern int mMsg_CopyItem(mMsg_Window_c* msg_p, int str_no, u8* data, int start_idx, int len, int article, + u32 capitalize); extern int mMsg_CopyMail(mMsg_Window_c* msg_p, int str_no, u8* data, int start_idx, int len, u32 capitalize); extern int mMsg_sound_voice_get(int code); extern int mMsg_sound_voice_get_for_editor(int code); @@ -339,6 +342,29 @@ extern void mMsg_sound_set_voice_click(mMsg_Window_c* msg_p); extern void mMsg_sound_set_voice_silent(mMsg_Window_c* msg_p, int update_mode); extern void mMsg_sound_unset_voice_silent(mMsg_Window_c* msg_p, int update_mode); +/* Macros */ + +#define mMsg_SET_CONTINUE_MSG_NUM(msg_no) mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), (msg_no)) +#define mMsg_SET_LOCKCONTINUE() mMsg_Set_LockContinue(mMsg_Get_base_window_p()) +#define mMsg_UNSET_LOCKCONTINUE() mMsg_Unset_LockContinue(mMsg_Get_base_window_p()) +#define mMsg_SET_FORCENEXT() mMsg_Set_ForceNext(mMsg_Get_base_window_p()) +#define mMsg_SET_CANCELNORMALCONTINUE() mMsg_Set_CancelNormalContinue(mMsg_Get_base_window_p()) +#define mMsg_SET_ITEM_STR_ART(str_no, str, str_len, item_no) \ + mMsg_Set_item_str_art(mMsg_Get_base_window_p(), str_no, str, str_len, mIN_get_item_article(item_no)) +#define mMsg_SET_FREE_STR(str_no, str, str_len) mMsg_Set_free_str(mMsg_Get_base_window_p(), str_no, str, str_len) +#define mMsg_SET_FREE_STR_CL(str_no, str, str_len, cl) \ + mMsg_Set_free_str_cl(mMsg_Get_base_window_p(), str_no, str, str_len, cl) +#define mMsg_SET_FREE_STR_CL_ART(str_no, str, str_len, cl, item_no) \ + mMsg_Set_free_str_cl_art(mMsg_Get_base_window_p(), str_no, str, str_len, cl, mIN_get_item_article(item_no)) + +#define mMsg_GET_MSG_NUM() mMsg_Get_msg_num(mMsg_Get_base_window_p()) + +#define mMsg_CHECK_MAINNORMALCONTINUE() mMsg_Check_MainNormalContinue(mMsg_Get_base_window_p()) +#define mMsg_CHECK_MAINDISAPPEAR() mMsg_Check_MainDisappear(mMsg_Get_base_window_p()) +#define mMsg_CHECK_MAINHIDE() mMsg_Check_MainHide(mMsg_Get_base_window_p()) + +#define mMsg_REQUEST_MAIN_DISAPPEAR() mMsg_request_main_disappear(mMsg_Get_base_window_p()) + #ifdef __cplusplus } #endif diff --git a/include/m_player_lib.h b/include/m_player_lib.h index c2ae63ce..60d05841 100644 --- a/include/m_player_lib.h +++ b/include/m_player_lib.h @@ -17,7 +17,7 @@ extern void mPlib_Clear_controller_data_for_title_demo(); extern void mPlib_request_main_invade_type1(GAME_PLAY* play); extern mActor_name_t mPlib_Get_itemNo_forWindow(); extern int mPlib_check_able_change_camera_normal_index(); -extern void mPlib_request_main_refuse_type1(GAME_PLAY* play); +extern void mPlib_request_main_refuse_type1(GAME* game); extern void mPlib_request_main_wait_type3(GAME* game); extern void mPlib_Set_able_force_speak_label(ACTOR* actor); extern int mPlib_request_main_demo_walk_type1(GAME* game, f32 goal_x, f32 goal_z, f32 speed, int flag); @@ -63,6 +63,7 @@ extern void mPlib_Set_change_color_request(); extern int mPlib_check_player_open_umbrella(GAME_PLAY* play); extern int mPlib_Check_UKI_COMEBACK_STATUS(); extern int mPlib_check_player_actor_main_index_OutDoorMove(GAME_PLAY* play); +extern int mPlib_request_main_close_furniture_type1(GAME* game); extern mPlayer_change_data_from_submenu_c* mPlib_Get_change_data_from_submenu_p(); diff --git a/include/m_scene.h b/include/m_scene.h index 017aa6af..5d2a41c1 100644 --- a/include/m_scene.h +++ b/include/m_scene.h @@ -212,7 +212,7 @@ extern void Scene_ct(GAME_PLAY* play, Scene_Word_u* scene_data); extern void Door_info_ct(Door_info_c* door_info); extern int goto_other_scene(GAME_PLAY* play, Door_data_c* door_data, int update_player_mode); extern int goto_next_scene(GAME_PLAY* play, int next_idx, int update_player_mode); -extern int goto_emu_game(GAME_PLAY* play, u8 famicom_rom_id); +extern int goto_emu_game(GAME* game, s16 famicom_rom_id); extern void return_emu_game(GAME* game); #ifdef __cplusplus diff --git a/src/ac_airplane.c b/src/ac_airplane.c index c9d8f5e3..c58a37d9 100644 --- a/src/ac_airplane.c +++ b/src/ac_airplane.c @@ -334,15 +334,13 @@ static void aAp_CommonHandle(ACTOR* actor, AIRPLANE_ACTOR* airplane, GAME* game) } static void aAp_ZbuttonChangeStatus(AIRPLANE_ACTOR* actor, GAME* game) { - GAME_PLAY* play = (GAME_PLAY*)game; - if (chkButton(BUTTON_Z)) { if (actor->status == aAp_STATUS_PLAYER_CATCH) { - mPlib_request_main_refuse_type1(play); + mPlib_request_main_refuse_type1(game); actor->status = aAp_STATUS_START_FLY_MOVE; } } else if (actor->status == aAp_STATUS_START_FLY_MOVE) { - mPlib_request_main_wait_type3((GAME*)play); + mPlib_request_main_wait_type3(game); actor->status = aAp_STATUS_PLAYER_CATCH; } } diff --git a/src/ac_my_room.c b/src/ac_my_room.c index 36304007..681c9cf2 100644 --- a/src/ac_my_room.c +++ b/src/ac_my_room.c @@ -10,6 +10,10 @@ #include "m_cockroach.h" #include "m_msg.h" #include "dolphin/card.h" +#include "m_string.h" +#include "m_house.h" +#include "m_player_lib.h" +#include "GBA2/gba2.h" enum { aMR_ICON_LEAF, @@ -123,6 +127,10 @@ static int aMR_UnitNum2FtrItemNoFtrID(mActor_name_t* item_no, int* ftr_id, int u static void aMR_ReserveDefaultBgm(ACTOR* actorx, FTR_ACTOR* ftr_actor); static void aMR_ChangeMDBgm(ACTOR* actorx, FTR_ACTOR* ftr_actor); static void aMR_SetFurniture2FG(FTR_ACTOR* ftr_actor, xyz_t pos, int on_flag); +static int aMR_FtrIdx2ChangeFtrSwitch(ACTOR* actorx, int ftr_id); +static aFTR_PROFILE* aMR_GetFurnitureProfile(u16 ftr_no); + +#include "../src/ac_my_room_msg_ctrl.c_inc" static aFTR_PROFILE* aMR_GetFurnitureProfile(u16 ftr_no) { if (ftr_no < FTR_NUM) { diff --git a/src/ac_my_room_msg_ctrl.c_inc b/src/ac_my_room_msg_ctrl.c_inc new file mode 100644 index 00000000..cc04018f --- /dev/null +++ b/src/ac_my_room_msg_ctrl.c_inc @@ -0,0 +1,2039 @@ +static void aMR_SetSlotString(void) { + u8 str[mMsg_FREE_STRING_LEN]; + int slot = famicom_getErrorChan(); + + mString_Load_StringFromRom(str, mMsg_FREE_STRING_LEN, 0x6CD + (slot & 1)); + mMsg_Set_free_str(mMsg_Get_base_window_p(), mMsg_FREE_STR4, str, mMsg_FREE_STRING_LEN); +} + +static int aMR_GetCardFamicomCount(void) { + int count = 0; + + if (famicom_get_disksystem_titles(&count, NULL, 0) != FALSE) { + return count; + } + + return 0; +} + +static u8* aMR_GetNameString(MY_ROOM_ACTOR* my_room, int rom_no) { + static u8 dummy[FAMICOM_MORI_NAME_LEN] = { 'n', 'o', ' ', 'g', 'a', 'm', 'e', ' ', + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }; + + if (my_room->emu_info.famicom_names_p != NULL && rom_no < my_room->emu_info.card_famicom_count) { + return (u8*)my_room->emu_info.famicom_names_p + rom_no * FAMICOM_MORI_NAME_LEN; + } + + return dummy; +} + +static void aMR_SetMemoryCardGameIndex(MY_ROOM_ACTOR* my_room, int sub_index) { + my_room->emu_info.rom_no = -(my_room->emu_info.memory_game_select + sub_index); +} + +static void aMR_ReportDisplayMemoryGameSelectCount(MY_ROOM_ACTOR* my_room, int add_amount) { + my_room->emu_info.memory_game_select += add_amount; + + if (my_room->emu_info.memory_game_select >= my_room->emu_info.card_famicom_count) { + my_room->emu_info.memory_game_select = 0; + } +} + +static FTR_ACTOR* aMR_GetNowDemoFtr(ACTOR* actorx) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + return l_aMR_work.ftr_actor_list + my_room->demo_ftrID; +} + +static void aMR_ChangeDemoFtrStatus(ACTOR* actorx, s16 status) { + FTR_ACTOR* ftr_actor = aMR_GetNowDemoFtr(actorx); + + ftr_actor->demo_status = status; +} + +static int aMR_GetMusicCountInMusicBox(void) { + int i; + int count = 0; + + for (i = 0; i < MINIDISK_NUM; i++) { + u32* music_box = Save_Get(scene_no) == SCENE_COTTAGE_MY + ? Save_Get(island).cottage.music_box + : Save_Get(homes[mHS_get_arrange_idx(Common_Get(player_no))]).music_box; + + if (((music_box[(i / 32) & 1] >> (i & 31)) & 1) == 1) { + count++; + } + } + + return count; +} + +static void aMR_MemoryMusicBoxStatus(MY_ROOM_ACTOR* my_room) { + u32* music_box = Save_Get(scene_no) == SCENE_COTTAGE_MY + ? Save_Get(island).cottage.music_box + : Save_Get(homes[mHS_get_arrange_idx(Common_Get(player_no))]).music_box; + int i; + + for (i = 0; i < 2; i++) { + my_room->music_box[i] = music_box[i]; + } +} + +static void aMR_SetEmulatorMessage_CanSave(ACTOR* actorx) { + mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), 0x17B5); + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + mMsg_Set_ForceNext(mMsg_Get_base_window_p()); +} + +static void aMR_SetEmulatorStartMessage(ACTOR* actorx, int internal_rom) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + int res; + + Common_Get(my_room_message_control_flags) |= (1 << 2); + + if (internal_rom == TRUE) { + res = famicom_internal_data_load(); + } else { + if (Common_Get(player_no) < PLAYER_NUM) { + aMR_SetEmulatorMessage_CanSave(actorx); + aMR_SetSlotString(); + return; + } + + res = famicom_external_data_save_check(); + } + + aMR_SetSlotString(); + + switch (res) { + case FAMICOM_RESULT_OK: + my_room->requested_msg_type = aMR_MSG_STATE_EXPLAIN_EMULATOR; + aMR_SetEmulatorMessage_CanSave(actorx); + break; + case FAMICOM_RESULT_NOSPACE: + my_room->requested_msg_type = aMR_MSG_STATE_EXPLAIN_EMULATOR; + mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), 0x3B50); + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + mMsg_Set_ForceNext(mMsg_Get_base_window_p()); + break; + case FAMICOM_RESULT_NOENTRY: + my_room->requested_msg_type = aMR_MSG_STATE_EXPLAIN_EMULATOR; + mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), 0x3B51); + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + mMsg_Set_ForceNext(mMsg_Get_base_window_p()); + break; + case FAMICOM_RESULT_BROKEN: + my_room->requested_msg_type = aMR_MSG_STATE_EXPLAIN_EMULATOR; + mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), 0x3B52); + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + mMsg_Set_ForceNext(mMsg_Get_base_window_p()); + break; + case FAMICOM_RESULT_WRONGDEVICE: + my_room->requested_msg_type = aMR_MSG_STATE_EXPLAIN_EMULATOR; + mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), 0x3B53); + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + mMsg_Set_ForceNext(mMsg_Get_base_window_p()); + break; + case FAMICOM_RESULT_WRONGENCODING: + my_room->requested_msg_type = aMR_MSG_STATE_EXPLAIN_EMULATOR; + mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), 0x3B54); + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + mMsg_Set_ForceNext(mMsg_Get_base_window_p()); + break; + case FAMICOM_RESULT_NOCARD: + my_room->requested_msg_type = aMR_MSG_STATE_EXPLAIN_EMULATOR; + mMsg_Set_free_str(mMsg_Get_base_window_p(), mMsg_FREE_STR0, Save_Get(land_info).name, LAND_NAME_SIZE); + mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), 0x3B55); + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + mMsg_Set_ForceNext(mMsg_Get_base_window_p()); + break; + case FAMICOM_RESULT_NOFILE: + default: + mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), 0x3071); + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + mMsg_Set_ForceNext(mMsg_Get_base_window_p()); + my_room->requested_msg_type = aMR_MSG_STATE_WAIT_FAMICOM_BATU; + Common_Get(my_room_message_control_flags) &= ~4; + break; + } +} + +static void aMR_NoMsgInit(ACTOR* actorx) { + // nothing +} + +static void aMR_NoMsgControl(ACTOR* actorx, GAME* game) { + // nothing +} + +static void aMR_MsgControlOwnerNoItem(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + int choice = mChoice_Get_ChoseNum(mChoice_Get_base_window_p()); + + if (choice != -1) { + switch (choice) { + case mChoice_CHOICE0: { + if (mSM_check_open_inventory_itemlist(mSM_IV_OPEN_PUTIN_FTR, 0) == FALSE) { + my_room->requested_msg_type = aMR_MSG_STATE_REQUEST_CLOSE_FTR; + mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), 0x0A10); + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + } else { + my_room->requested_msg_type = aMR_MSG_STATE_OPEN_SUBMENU; + mMsg_Set_CancelNormalContinue(mMsg_Get_base_window_p()); + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + } + + break; + } + + default: { + my_room->requested_msg_type = aMR_MSG_STATE_REQUEST_CLOSE_FTR; + mMsg_Set_CancelNormalContinue(mMsg_Get_base_window_p()); + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + break; + } + } + } +} + +static void aMR_MsgInitOwnerWhichPutOut(ACTOR* actorx) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + static u8 item_name1[mIN_ITEM_NAME_LEN]; + static u8 item_name2[mIN_ITEM_NAME_LEN]; + static u8 item_name3[mIN_ITEM_NAME_LEN]; + static u8* item_name_table[] = { item_name1, item_name2, item_name3 }; + u8 cancel_str[mChoice_CHOICE_STRING_LEN]; + FTR_ACTOR* ftr_actor = l_aMR_work.ftr_actor_list + my_room->demo_ftrID; + mChoice_c* choice_win = mChoice_Get_base_window_p(); + int count; + int i; + + aMR_TidyItemInFurniture(ftr_actor); + count = aMR_GetItemCountInFurniture(ftr_actor); + mChoice_Clear_ChoseNum(choice_win); + + for (i = 0; i < count; i++) { + if (ftr_actor->items[i] != EMPTY_NO) { + mIN_copy_name_str(item_name_table[i], ftr_actor->items[i]); + } + } + + if (my_room->msg_type == aMR_MSG_STATE_OWNER_WHICH_PUT_OUT1) { + for (i = 0; i < aFTR_KEEP_ITEM_COUNT; i++) { + if (ftr_actor->items[i] != EMPTY_NO) { + mMsg_Set_item_str_art(mMsg_Get_base_window_p(), i, item_name_table[i], mIN_ITEM_NAME_LEN, + mIN_get_item_article(ftr_actor->items[i])); + } + } + } + + mChoice_Load_ChoseStringFromRom(choice_win, cancel_str, 0x29, NULL); + if (count == 1) { + mChoice_Set_choice_data(choice_win, item_name_table[0], mIN_ITEM_NAME_LEN, cancel_str, + mChoice_CHOICE_STRING_LEN, NULL, mIN_ITEM_NAME_LEN, NULL, mIN_ITEM_NAME_LEN, NULL, + mIN_ITEM_NAME_LEN, NULL, mIN_ITEM_NAME_LEN); + } else if (count == 2) { + mChoice_Set_choice_data(choice_win, item_name_table[0], mIN_ITEM_NAME_LEN, item_name_table[1], + mIN_ITEM_NAME_LEN, cancel_str, mChoice_CHOICE_STRING_LEN, NULL, mIN_ITEM_NAME_LEN, NULL, + mIN_ITEM_NAME_LEN, NULL, mIN_ITEM_NAME_LEN); + } else if (count == 3) { + mChoice_Set_choice_data(choice_win, item_name_table[0], mIN_ITEM_NAME_LEN, item_name_table[1], + mIN_ITEM_NAME_LEN, item_name_table[2], mIN_ITEM_NAME_LEN, cancel_str, + mChoice_CHOICE_STRING_LEN, NULL, mIN_ITEM_NAME_LEN, NULL, mIN_ITEM_NAME_LEN); + } +} + +static void aMR_MsgControlOwnerWhichPutOut(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + int choice_no = mChoice_Get_ChoseNum(mChoice_Get_base_window_p()); + + mChoice_Clear_ChoseNum(mChoice_Get_base_window_p()); + if (choice_no != -1) { + FTR_ACTOR* ftr_actor = aMR_GetNowDemoFtr(actorx); + + if (choice_no < aMR_GetItemCountInFurniture(ftr_actor)) { + int idx = mPr_GetPossessionItemIdxWithCond(Common_Get(now_private), EMPTY_NO, mPr_ITEM_COND_NORMAL); + + if (idx != -1) { + mActor_name_t item = ftr_actor->items[choice_no]; + + ftr_actor->items[choice_no] = EMPTY_NO; + aMR_TidyItemInFurniture(ftr_actor); + my_room->requested_msg_type = aMR_MSG_STATE_REQUEST_CLOSE_FTR; + mPr_SetPossessionItem(Common_Get(now_private), idx, item, mPr_ITEM_COND_NORMAL); + mMsg_Set_CancelNormalContinue(mMsg_Get_base_window_p()); + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + } else { + /* Full pockets */ + my_room->requested_msg_type = aMR_MSG_STATE_REQUEST_CLOSE_FTR; + mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), 0x0A0E); + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + } + } else { + /* Cancelled */ + my_room->requested_msg_type = aMR_MSG_STATE_REQUEST_CLOSE_FTR; + mMsg_Set_CancelNormalContinue(mMsg_Get_base_window_p()); + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + } + } +} + +static void aMR_MsgInitOwnerWaitWhichPutOut(ACTOR* actorx) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + if (mMsg_Check_MainNormalContinue(mMsg_Get_base_window_p())) { + my_room->requested_msg_type = aMR_MSG_STATE_OWNER_WHICH_PUT_OUT3; + mChoice_no_b_close_set(mChoice_Get_base_window_p()); + } +} + +static void aMR_MsgControlOwnerWaitWhichPutOut(ACTOR* actorx, GAME* game) { + aMR_MsgInitOwnerWaitWhichPutOut(actorx); +} + +static void aMR_MsgInitOwnerExistItem(ACTOR* actorx) { + u8 item_str[mIN_ITEM_NAME_LEN]; + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + int demo_ftrID = my_room->demo_ftrID; + FTR_ACTOR* ftr_actor = &l_aMR_work.ftr_actor_list[demo_ftrID]; + int i; + + for (i = 0; i < aFTR_KEEP_ITEM_COUNT; i++) { + if (ftr_actor->items[i] != EMPTY_NO) { + mIN_copy_name_str(item_str, ftr_actor->items[i]); + mMsg_Set_item_str_art(mMsg_Get_base_window_p(), i, item_str, mIN_ITEM_NAME_LEN, + mIN_get_item_article(ftr_actor->items[i])); + } + } +} + +static void aMR_MsgControlOwnerExistItem(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + int idx = mPr_GetPossessionItemIdxWithCond(Common_Get(now_private), EMPTY_NO, mPr_ITEM_COND_NORMAL); + int choice_no = mChoice_Get_ChoseNum(mChoice_Get_base_window_p()); + + mChoice_Clear_ChoseNum(mChoice_Get_base_window_p()); + + if (choice_no != -1) { + if (choice_no == mChoice_CHOICE0) { + if (mSM_check_open_inventory_itemlist(mSM_IV_OPEN_PUTIN_FTR, 0) == FALSE) { + my_room->requested_msg_type = aMR_MSG_STATE_REQUEST_CLOSE_FTR; + mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), 0x0A10); + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + } else { + my_room->requested_msg_type = aMR_MSG_STATE_OPEN_SET_ITEM_SUBMENU; + mMsg_Set_CancelNormalContinue(mMsg_Get_base_window_p()); + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + } + } else if (choice_no == mChoice_CHOICE1) { + FTR_ACTOR* ftr_actor = aMR_GetNowDemoFtr(actorx); + + if (idx != -1) { + mActor_name_t item = ftr_actor->items[0]; + + ftr_actor->items[0] = EMPTY_NO; + aMR_TidyItemInFurniture(ftr_actor); + my_room->requested_msg_type = aMR_MSG_STATE_REQUEST_CLOSE_FTR; + mPr_SetPossessionItem(Common_Get(now_private), idx, item, mPr_ITEM_COND_NORMAL); + mMsg_Set_CancelNormalContinue(mMsg_Get_base_window_p()); + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + } else { + /* Full pockets */ + my_room->requested_msg_type = aMR_MSG_STATE_REQUEST_CLOSE_FTR; + mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), 0x0A0E); + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + } + } else { + my_room->requested_msg_type = aMR_MSG_STATE_REQUEST_CLOSE_FTR; + mMsg_Set_CancelNormalContinue(mMsg_Get_base_window_p()); + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + } + } +} + +static void aMR_MsgControlOwnerExistItem_ItemCount2(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + int idx = mPr_GetPossessionItemIdxWithCond(Common_Get(now_private), EMPTY_NO, mPr_ITEM_COND_NORMAL); + int choice_no = mChoice_Get_ChoseNum(mChoice_Get_base_window_p()); + + mChoice_Clear_ChoseNum(mChoice_Get_base_window_p()); + + if (choice_no != -1) { + if (choice_no == mChoice_CHOICE0) { + if (mSM_check_open_inventory_itemlist(mSM_IV_OPEN_PUTIN_FTR, 0) == FALSE) { + my_room->requested_msg_type = aMR_MSG_STATE_REQUEST_CLOSE_FTR; + mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), 0x0A10); + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + } else { + my_room->requested_msg_type = aMR_MSG_STATE_OPEN_SET_ITEM_SUBMENU; + mMsg_Set_CancelNormalContinue(mMsg_Get_base_window_p()); + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + } + } else if (choice_no == mChoice_CHOICE1) { + if (idx != -1) { + my_room->requested_msg_type = aMR_MSG_STATE_OWNER_WAIT_WHICH_PUT_OUT; + mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), 0x2F1E); + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + } else { + /* Full pockets */ + my_room->requested_msg_type = aMR_MSG_STATE_REQUEST_CLOSE_FTR; + mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), 0x0A0E); + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + } + } else { + my_room->requested_msg_type = aMR_MSG_STATE_REQUEST_CLOSE_FTR; + mMsg_Set_CancelNormalContinue(mMsg_Get_base_window_p()); + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + } + } +} + +static void aMR_MsgControlOtherNoItem(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + if (mMsg_Check_MainDisappear(mMsg_Get_base_window_p())) { + my_room->requested_msg_type = aMR_MSG_STATE_REQUEST_CLOSE_FTR; + } +} + +static void aMR_MsgControlOtherExistItem(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + if (mMsg_Check_MainDisappear(mMsg_Get_base_window_p())) { + my_room->requested_msg_type = aMR_MSG_STATE_REQUEST_CLOSE_FTR; + } +} + +static void aMR_MsgInitFullPlayerItem(ACTOR* actorx) { + // nothing +} + +static void aMR_MsgControlFullPlayerItem(ACTOR* actorx, GAME* game) { + if (mDemo_Check(mDemo_TYPE_REPORT, actorx) == FALSE) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + } +} + +static void aMR_MsgControlOpenSubmenu(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + GAME_PLAY* play = (GAME_PLAY*)game; + Submenu* submenu = &play->submenu; + + if (mDemo_CheckDemo() == FALSE) { + mSM_open_submenu(submenu, mSM_OVL_INVENTORY, mSM_IV_OPEN_PUTIN_FTR, 0); + mChoice_Clear_ChoseNum(mChoice_Get_base_window_p()); + my_room->requested_msg_type = aMR_MSG_STATE_ITEM_PUT_IN; + } +} + +static void aMR_MsgControlItemPutIn(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + GAME_PLAY* play = (GAME_PLAY*)game; + Submenu* submenu = &play->submenu; + + if (submenu->process_status == mSM_PROCESS_WAIT) { + Submenu_Item_c* submenu_item = submenu->item_p; + + if (submenu_item != NULL && submenu_item->item != EMPTY_NO) { + FTR_ACTOR* ftr_actor = aMR_GetNowDemoFtr(actorx); + + aMR_ItemPutInFurniture(ftr_actor, submenu_item->item); + } + + if (mPlib_request_main_close_furniture_type1(game)) { + aMR_ChangeDemoFtrStatus(actorx, 5); + my_room->requested_msg_type = aMR_MSG_STATE_WAIT_CLOSE_FTR; + } + } +} + +static void aMR_MsgControlCanNotClean(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + my_room->requested_msg_type = aMR_MSG_STATE_NONE; +} + +static void aMR_MsgControlWaitCloseFtr(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + if (my_room->demo_flag == TRUE) { + FTR_ACTOR* ftr_actor = &l_aMR_work.ftr_actor_list[my_room->demo_ftrID]; + + if (ftr_actor->demo_status == 0) { + my_room->demo_flag = FALSE; + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + } + } else { + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + my_room->demo_ftrID = 0; + } +} + +static void aMR_MsgInitRequestCloseFtr(ACTOR* actorx) { + // nothing +} + +static void aMR_MsgControlRequestCloseFtr(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + if (mMsg_CHECK_MAINDISAPPEAR() || mMsg_CHECK_MAINHIDE()) { + if (mPlib_request_main_close_furniture_type1(game)) { + aMR_ChangeDemoFtrStatus(actorx, 5); + my_room->requested_msg_type = aMR_MSG_STATE_WAIT_CLOSE_FTR; + } + } +} + +static void aMR_MsgControlOpenSetItemSubmenu(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + GAME_PLAY* play = (GAME_PLAY*)game; + Submenu* submenu = &play->submenu; + + if (mDemo_CheckDemo() == FALSE) { + mSM_open_submenu(submenu, mSM_OVL_INVENTORY, mSM_IV_OPEN_PUTIN_FTR, 0); + mChoice_Clear_ChoseNum(mChoice_Get_base_window_p()); + my_room->requested_msg_type = aMR_MSG_STATE_ITEM_SET_SUBMENU; + } +} + +static void aMR_MsgControlItemSetSubmenu(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + GAME_PLAY* play = (GAME_PLAY*)game; + Submenu* submenu = &play->submenu; + + if (submenu->process_status == mSM_PROCESS_WAIT) { + Submenu_Item_c* submenu_item = submenu->item_p; + + if (submenu_item != NULL && submenu_item->item != EMPTY_NO) { + FTR_ACTOR* ftr_actor = aMR_GetNowDemoFtr(actorx); + + aMR_ItemPutInFurniture(ftr_actor, submenu_item->item); + } + + if (mPlib_request_main_close_furniture_type1(game)) { + aMR_ChangeDemoFtrStatus(actorx, 5); + my_room->requested_msg_type = aMR_MSG_STATE_WAIT_CLOSE_FTR; + } + } +} + +static void aMR_MsgControlOwnerNoMD(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + int choice_no = mChoice_Get_ChoseNum(mChoice_Get_base_window_p()); + + if (choice_no != -1) { + switch (choice_no) { + case mChoice_CHOICE0: { + if (mSM_check_open_inventory_itemlist(mSM_IV_OPEN_MINIDISK, 0) == FALSE) { + my_room->requested_msg_type = aMR_MSG_STATE_REQUEST_CLOSE_MD; + mMsg_SET_CONTINUE_MSG_NUM(0x10BD); + mMsg_UNSET_LOCKCONTINUE(); + } else { + my_room->requested_msg_type = aMR_MSG_STATE_OPENMD_SUBMENU; + mMsg_SET_CANCELNORMALCONTINUE(); + mMsg_UNSET_LOCKCONTINUE(); + } + break; + } + + case mChoice_CHOICE1: { + if (aMR_GetMusicCountInMusicBox() == 0) { + my_room->requested_msg_type = aMR_MSG_STATE_REQUEST_CLOSE_MD; + mMsg_SET_CONTINUE_MSG_NUM(0x2F28); + mMsg_UNSET_LOCKCONTINUE(); + } else { + my_room->requested_msg_type = aMR_MSG_STATE_OPEN_MUSIC_BOX; + mMsg_SET_CANCELNORMALCONTINUE(); + mMsg_UNSET_LOCKCONTINUE(); + } + + break; + } + + default: { + my_room->requested_msg_type = aMR_MSG_STATE_REQUEST_CLOSE_MD; + mMsg_SET_CANCELNORMALCONTINUE(); + mMsg_UNSET_LOCKCONTINUE(); + break; + } + } + } +} + +static void aMR_MsgInitOwnerExistMD(ACTOR* actorx) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + int demo_ftrID = my_room->demo_ftrID; + FTR_ACTOR* ftr_actor = &l_aMR_work.ftr_actor_list[demo_ftrID]; + mActor_name_t item = ftr_actor->items[0]; + u8 item_name[mIN_ITEM_NAME_LEN]; + + mIN_copy_name_str(item_name, item); + mMsg_SET_ITEM_STR_ART(mMsg_ITEM_STR0, item_name, mIN_ITEM_NAME_LEN, item); +} + +static void aMR_MsgControlOwnerExistMD(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + int choice_no = mChoice_GET_CHOSENUM(); + + mChoice_CLEAR_CHOSENUM(); + if (choice_no != -1) { + if (choice_no == mChoice_CHOICE0) { + if (mSM_check_open_inventory_itemlist(mSM_IV_OPEN_MINIDISK, 0) == FALSE) { + my_room->requested_msg_type = aMR_MSG_STATE_REQUEST_CLOSE_MD; + mMsg_SET_CONTINUE_MSG_NUM(0x10BD); + mMsg_UNSET_LOCKCONTINUE(); + } else { + my_room->requested_msg_type = aMR_MSG_STATE_OPENMD_SUBMENU; + mMsg_SET_CANCELNORMALCONTINUE(); + mMsg_UNSET_LOCKCONTINUE(); + } + } else if (choice_no == mChoice_CHOICE1) { + if (aMR_GetMusicCountInMusicBox() == 0) { + my_room->requested_msg_type = aMR_MSG_STATE_REQUEST_CLOSE_MD; + mMsg_SET_CONTINUE_MSG_NUM(0x2F28); + mMsg_UNSET_LOCKCONTINUE(); + } else { + my_room->requested_msg_type = aMR_MSG_STATE_OPEN_MUSIC_BOX; + mMsg_SET_CANCELNORMALCONTINUE(); + mMsg_UNSET_LOCKCONTINUE(); + } + } else if (choice_no == mChoice_CHOICE2) { + my_room->requested_msg_type = aMR_MSG_STATE_REQUEST_CLOSE_MD; + aMR_FtrIdx2ChangeFtrSwitch(actorx, my_room->demo_ftrID); + mMsg_SET_CANCELNORMALCONTINUE(); + mMsg_UNSET_LOCKCONTINUE(); + } else { + my_room->requested_msg_type = aMR_MSG_STATE_REQUEST_CLOSE_MD; + mMsg_SET_CANCELNORMALCONTINUE(); + mMsg_UNSET_LOCKCONTINUE(); + } + } +} + +static void aMR_MsgControlOtherNoMD(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + if (mMsg_Check_MainDisappear(mMsg_Get_base_window_p())) { + my_room->requested_msg_type = aMR_MSG_STATE_REQUEST_CLOSE_MD; + } +} + +static void aMR_MsgControlOtherExistMD(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + if (mMsg_Check_MainDisappear(mMsg_Get_base_window_p())) { + my_room->requested_msg_type = aMR_MSG_STATE_REQUEST_CLOSE_MD; + aMR_FtrIdx2ChangeFtrSwitch(actorx, my_room->demo_ftrID); + } +} + +static void aMR_MsgControlFullPlayerMD(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + my_room->requested_msg_type = aMR_MSG_STATE_NONE; +} + +static void aMR_MsgControlOpenMusicBox(ACTOR* actorx, GAME* game) { + FTR_ACTOR* ftr_actor = aMR_GetNowDemoFtr(actorx); + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + GAME_PLAY* play = (GAME_PLAY*)game; + Submenu* submenu = &play->submenu; + + if (mDemo_CheckDemo() == FALSE) { + int md_idx = (ftr_actor->items[0] >= ITM_MINIDISK_START && ftr_actor->items[0] < ITM_MINIDISK_END) + ? (mActor_name_t)(ftr_actor->items[0] - ITM_MINIDISK_START) + : -1; + + aMR_MemoryMusicBoxStatus(my_room); + mSM_open_submenu(submenu, mSM_OVL_MUSIC, md_idx, 0); + mChoice_CLEAR_CHOSENUM(); + my_room->requested_msg_type = aMR_MSG_STATE_MUSIC_BOX_MD_PUT_IN; + } +} + +static void aMR_DeleteDirectedMD(ACTOR* actorx) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + FTR_ACTOR* ftr_actor = l_aMR_work.ftr_actor_list; + u8* used = l_aMR_work.used_list; + int i; + + for (i = 0; i < l_aMR_work.list_size; i++) { + if (*used) { + aFTR_PROFILE* profile = aMR_GetFurnitureProfile(ftr_actor->name); + + if (aFTR_CHECK_INTERACTION(profile->interaction_type, aFTR_INTERACTION_TYPE_MUSIC_DISK) && + (ftr_actor->items[0] >= ITM_MINIDISK_START && ftr_actor->items[0] < ITM_MINIDISK_END)) { + int md_idx = (mActor_name_t)(ftr_actor->items[0] - ITM_MINIDISK_START); + u32* music_box = Save_Get(scene_no) == SCENE_COTTAGE_MY + ? Save_Get(island).cottage.music_box + : Save_Get(homes[mHS_get_arrange_idx(Common_Get(player_no))]).music_box; + + if (((music_box[(md_idx / 32) & 1] >> (md_idx & 31)) & 1) == 0) { + if (ftr_actor->switch_bit == TRUE) { + aMR_AllMDSwitchOff(); + ftr_actor->items[0] = EMPTY_NO; + aMR_OneMDSwitchOn_TheOtherSwitchOff(ftr_actor); + aMR_ReserveDefaultBgm(actorx, ftr_actor); + aMR_ChangeMDBgm(actorx, ftr_actor); + sAdo_OngenTrgStart(0x17, &ftr_actor->position); + } else { + ftr_actor->items[0] = EMPTY_NO; + sAdo_OngenTrgStart(0x17, &ftr_actor->position); + } + + ftr_actor->switch_changed_flag = TRUE; + ftr_actor->switch_bit = FALSE; + } + } + } + + used++; + ftr_actor++; + } +} + +static void aMR_MsgControlMusicBoxMDPutIn(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + GAME_PLAY* play = (GAME_PLAY*)game; + Submenu* submenu = &play->submenu; + + if (submenu->process_status == mSM_PROCESS_WAIT) { + FTR_ACTOR* ftr_actor = aMR_GetNowDemoFtr(actorx); + + if (submenu->item_p != NULL && submenu->item_p->item != EMPTY_NO) { + ftr_actor->items[0] = submenu->item_p->item; + aMR_OneMDSwitchOn_TheOtherSwitchOff(ftr_actor); + aMR_ReserveBgm(actorx, BGM_MD0 + (ftr_actor->items[0] - ITM_MINIDISK_START), ftr_actor, 0); + aMR_ChangeMDBgm(actorx, ftr_actor); + } else { + aMR_DeleteDirectedMD(actorx); + } + + aMR_ChangeDemoFtrStatus(actorx, 5); + my_room->requested_msg_type = aMR_MSG_STATE_WAIT_CLOSE_MD; + } +} + +static void aMR_MsgControlOpenMDSubmenu(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + GAME_PLAY* play = (GAME_PLAY*)game; + Submenu* submenu = &play->submenu; + + if (mDemo_CheckDemo() == FALSE) { + aMR_MemoryMusicBoxStatus(my_room); + mSM_open_submenu(submenu, mSM_OVL_INVENTORY, mSM_IV_OPEN_MINIDISK, 0); + mChoice_CLEAR_CHOSENUM(); + my_room->requested_msg_type = aMR_MSG_STATE_MD_PUT_IN; + } +} + +static void aMR_MsgControlOpenExchangeMDSubmenu(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + GAME_PLAY* play = (GAME_PLAY*)game; + Submenu* submenu = &play->submenu; + + if (mDemo_CheckDemo() == FALSE) { + mSM_open_submenu(submenu, mSM_OVL_INVENTORY, mSM_IV_OPEN_MINIDISK, 0); + mChoice_CLEAR_CHOSENUM(); + my_room->requested_msg_type = aMR_MSG_STATE_MD_EXCHANGE_SUBMENU; + } +} + +static void aMR_MsgControlMDPutIn(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + GAME_PLAY* play = (GAME_PLAY*)game; + Submenu* submenu = &play->submenu; + + if (submenu->process_status == mSM_PROCESS_WAIT) { + FTR_ACTOR* ftr_actor = aMR_GetNowDemoFtr(actorx); + + if (submenu->item_p != NULL && submenu->item_p->item != EMPTY_NO) { + ftr_actor->items[0] = submenu->item_p->item; + aMR_OneMDSwitchOn_TheOtherSwitchOff(ftr_actor); + aMR_ReserveBgm(actorx, BGM_MD0 + (ftr_actor->items[0] - ITM_MINIDISK_START), ftr_actor, 0); + aMR_ChangeMDBgm(actorx, ftr_actor); + } + + aMR_ChangeDemoFtrStatus(actorx, 5); + my_room->requested_msg_type = aMR_MSG_STATE_WAIT_CLOSE_MD; + } +} + +static void aMR_MsgControlMDExchangeSubmenu(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + GAME_PLAY* play = (GAME_PLAY*)game; + Submenu* submenu = &play->submenu; + + if (submenu->process_status == mSM_PROCESS_WAIT) { + Submenu_Item_c* submenu_item = submenu->item_p; + + if (submenu_item != NULL && submenu_item->item != EMPTY_NO) { + FTR_ACTOR* ftr_actor = aMR_GetNowDemoFtr(actorx); + + mPr_SetFreePossessionItem(Now_Private, ftr_actor->items[0], mPr_ITEM_COND_NORMAL); + ftr_actor->items[0] = submenu_item->item; + aMR_OneMDSwitchOn_TheOtherSwitchOff(ftr_actor); + aMR_ReserveBgm(actorx, BGM_MD0 + (ftr_actor->items[0] - ITM_MINIDISK_START), ftr_actor, 0); + aMR_ChangeMDBgm(actorx, ftr_actor); + } + + aMR_ChangeDemoFtrStatus(actorx, 5); + my_room->requested_msg_type = aMR_MSG_STATE_WAIT_CLOSE_MD; + } +} + +static void aMR_MsgControlWaitCloseMD(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + if (my_room->demo_flag == TRUE) { + FTR_ACTOR* ftr_actor = &l_aMR_work.ftr_actor_list[my_room->demo_ftrID]; + + if (ftr_actor->demo_status == 0) { + my_room->state = 0; + my_room->demo_flag = FALSE; + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + } + } else { + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + my_room->demo_ftrID = 0; + } +} + +static void aMR_MsgInitRequestCloseMD(ACTOR* actorx) { + // nothing +} + +static void aMR_MsgControlRequestCloseMD(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + if (mMsg_CHECK_MAINDISAPPEAR() != FALSE || mMsg_CHECK_MAINHIDE() != FALSE) { + aMR_ChangeDemoFtrStatus(actorx, 5); + my_room->requested_msg_type = aMR_MSG_STATE_WAIT_CLOSE_MD; + } +} + +static void aMR_MsgControlCanNotMDClean(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + my_room->requested_msg_type = aMR_MSG_STATE_NONE; +} + +static void aMR_MsgInitPrepareCommunication(ACTOR* actorx) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + my_room->agb_connect_tries = 0; + mGcgba_InitVar(); +} + +static void aMR_MsgControlPrepareCommunication(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + if (mMsg_CHECK_MAINNORMALCONTINUE()) { + /* Check that the current message is the 'send to GBA' message */ + if (mMsg_GET_MSG_NUM() == 0x3DCE) { + mMsg_SET_LOCKCONTINUE(); + + switch (mGcgba_ConnectEnabled()) { + case GBA2_GBA_STATE_SUCCESS: + mGcgba_InitVar(); + my_room->requested_msg_type = aMR_MSG_STATE_START_EMU_DOWN_LOAD; + break; + + case GBA2_GBA_STATE_TRANSMITTING: + break; + + default: + if (my_room->agb_connect_tries > 60) { + my_room->requested_msg_type = aMR_MSG_STATE_NOT_CONNECT_AGB; + mMsg_SET_CONTINUE_MSG_NUM(0x3DCF); /* GBA is not properly connected */ + mMsg_UNSET_LOCKCONTINUE(); + mGcgba_EndComm(); + } + + break; + } + + my_room->agb_connect_tries++; + } + } +} + +static void aMR_MsgInitNotConnectAgb(ACTOR* actorx) { + // nothing +} + +static void aMR_MsgControlNotConnectAgb(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + if (mMsg_CHECK_MAINDISAPPEAR() || mMsg_CHECK_MAINHIDE()) { + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + my_room->emu_info.request_flag = FALSE; + } +} + +static void aMR_MsgInitCheckAgbProgram(ACTOR* actorx) { + // nothing +} + +static void aMR_MsgControlCheckAgbProgram(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + switch (mGcgba_IsEditor()) { + case GBA2_GBA_STATE_ALREADY_EXIST: + case GBA2_GBA_STATE_SUCCESS: + my_room->requested_msg_type = aMR_MSG_STATE_DELETE_AGB_PROGRAMQ; + mMsg_SET_CONTINUE_MSG_NUM(0x3DD0); /* Already has GBA program */ + mMsg_UNSET_LOCKCONTINUE(); + break; + + case GBA2_GBA_STATE_ERROR: + my_room->requested_msg_type = aMR_MSG_STATE_START_EMU_DOWN_LOAD; + break; + } +} + +static void aMR_MsgInitDeleteAgbProgramQ(ACTOR* actorx) { + // nothing +} + +static void aMR_MsgControlDeleteAgbProgramQ(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + int choice_no = mChoice_GET_CHOSENUM(); + + if (choice_no != -1) { + switch (choice_no) { + case mChoice_CHOICE0: + my_room->requested_msg_type = aMR_MSG_STATE_RECHECK_AGB_CONNECT; + mMsg_SET_CONTINUE_MSG_NUM(0x3DD2); + mMsg_UNSET_LOCKCONTINUE(); + break; + default: + my_room->requested_msg_type = aMR_MSG_STATE_NOT_CONNECT_AGB; + mMsg_SET_CONTINUE_MSG_NUM(0x3DD1); + mMsg_UNSET_LOCKCONTINUE(); + break; + } + } +} + +static void aMR_MsgInitStartEmuDownLoad(ACTOR* actorx) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + my_room->famicom_agb_image_p = famicom_gba_getImage(my_room->emu_info.agb_rom_no, &my_room->agb_game_size); + mGcgba_InitVar(); + mMsg_SET_LOCKCONTINUE(); + sAdo_SysLevStart(0x47); +} + +static void aMR_MsgControlStartEmuDownLoad(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + switch (mGcgba_Boot((u8*)my_room->famicom_agb_image_p, my_room->agb_game_size)) { + case GBA2_GBA_STATE_SUCCESS: + sAdo_SysLevStop(0x47); + famicom_gba_removeImage(my_room->famicom_agb_image_p); + mGcgba_InitVar(); + mGcgba_EndComm(); + my_room->requested_msg_type = aMR_MSG_STATE_NOT_CONNECT_AGB; + mMsg_SET_CONTINUE_MSG_NUM(0x3DD3); /* Data transmission complete */ + mMsg_UNSET_LOCKCONTINUE(); + mMsg_SET_FORCENEXT(); + break; + + case GBA2_GBA_STATE_TRANSMITTING: + break; + + default: + sAdo_SysLevStop(0x47); + famicom_gba_removeImage(my_room->famicom_agb_image_p); + mGcgba_InitVar(); + mGcgba_EndComm(); + my_room->requested_msg_type = aMR_MSG_STATE_NOT_CONNECT_AGB; + mMsg_SET_CONTINUE_MSG_NUM(0x3DD4); /* Data transmission failed */ + mMsg_UNSET_LOCKCONTINUE(); + mMsg_SET_FORCENEXT(); + break; + } +} + +static void aMR_MsgInitRecheckAgbConnect(ACTOR* actorx) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + mGcgba_EndComm(); + my_room->agb_connect_tries = 0; +} + +static void aMR_MsgControlRecheckAgbConnect(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + if (mMsg_CHECK_MAINNORMALCONTINUE()) { + /* Check that the current message is the 'reconnect GBA' message */ + if (mMsg_GET_MSG_NUM() == 0x3DD2) { + mMsg_SET_LOCKCONTINUE(); + + switch (mGcgba_ConnectEnabled()) { + case GBA2_GBA_STATE_SUCCESS: + mGcgba_InitVar(); + my_room->requested_msg_type = aMR_MSG_STATE_START_EMU_DOWN_LOAD; + break; + + case GBA2_GBA_STATE_TRANSMITTING: + break; + + default: + if (my_room->agb_connect_tries > 60) { + my_room->requested_msg_type = aMR_MSG_STATE_NOT_CONNECT_AGB; + mMsg_SET_CONTINUE_MSG_NUM(0x3DCF); /* GBA is not properly connected */ + mMsg_UNSET_LOCKCONTINUE(); + } + + break; + } + + my_room->agb_connect_tries++; + } + } +} + +static void aMR_MsgInitQqqEmulator(ACTOR* actorx) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + FTR_ACTOR* ftr_actor = &l_aMR_work.ftr_actor_list[my_room->emu_ftrID]; + + if (ftr_actor != NULL) { + static u8 ftr_name[mIN_ITEM_NAME_LEN]; + mActor_name_t emu_item = mRmTp_FtrIdx2FtrItemNo(ftr_actor->name, mRmTp_DIRECT_SOUTH); + + mIN_copy_name_str(ftr_name, emu_item); + mMsg_SET_FREE_STR_CL_ART(mMsg_FREE_STR1, ftr_name, sizeof(ftr_name), 5, emu_item); + } +} + +static void aMR_MsgControlQqqEmulator(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + int choice_no = mChoice_GET_CHOSENUM(); + + if (choice_no != -1) { + mChoice_NO_B_CLOSE_SET(); + + switch (choice_no) { + case mChoice_CHOICE0: + aMR_SetEmulatorStartMessage(actorx, TRUE); + break; + case mChoice_CHOICE1: + if (my_room->emu_info.agb_rom_no != 255) { + my_room->requested_msg_type = aMR_MSG_STATE_PREPARE_COMMUNICATION; + mMsg_SET_CONTINUE_MSG_NUM(0x3DCE); /* GBA */ + mMsg_UNSET_LOCKCONTINUE(); + mMsg_SET_FORCENEXT(); + } else { + my_room->requested_msg_type = aMR_MSG_STATE_NOT_CONNECT_AGB; + mMsg_SET_CONTINUE_MSG_NUM(0x3B57); /* Can't play on GBA */ + mMsg_SET_FORCENEXT(); + } + break; + default: + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + my_room->emu_info.request_flag = FALSE; + mMsg_SET_CANCELNORMALCONTINUE(); + mMsg_UNSET_LOCKCONTINUE(); + mMsg_SET_FORCENEXT(); + break; + } + } +} + +static void aMR_MsgInitWarningCannotMakeSaveFile(ACTOR* actorx) { + // nothing +} + +static void aMR_MsgControlWarningCannotMakeSaveFile(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + /* Check message is 'cannot create a new file' */ + if (mMsg_GET_MSG_NUM() == 0x306A) { + my_room->requested_msg_type = aMR_MSG_STATE_EXPLAIN_EMULATOR; + mMsg_SET_CONTINUE_MSG_NUM(0x17B5); /* Press L+R+Z to quit playing */ + mMsg_UNSET_LOCKCONTINUE(); + } +} + +static void aMR_MsgInitExplainEmulator(ACTOR* actorx) { + // nothing +} + +static void aMR_MsgControlExplainEmulator(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + /* Check message is 'cannot create a new file' */ + if (mMsg_CHECK_MAINDISAPPEAR()) { + my_room->emu_info.explaination_given_flag = TRUE; + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + } +} + +static void aMR_MsgInitQqqEmulatorMemory1(ACTOR* actorx) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + mMsg_SET_FREE_STR_CL(mMsg_FREE_STR1, aMR_GetNameString(my_room, 0), mIN_ITEM_NAME_LEN, 5); +} + +static void aMR_MsgControlQqqEmulatorMemory1(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + int choice_no = mChoice_GET_CHOSENUM(); + + mChoice_NO_B_CLOSE_SET(); + if (choice_no != -1) { + switch (choice_no) { + case mChoice_CHOICE0: + my_room->emu_info.rom_no = 0; + my_room->requested_msg_type = aMR_MSG_STATE_EXPLAIN_EMULATOR_MEMORY; + aMR_SetEmulatorStartMessage(actorx, FALSE); + break; + case mChoice_CHOICE1: + my_room->requested_msg_type = aMR_MSG_STATE_NOT_CONNECT_AGB; + mMsg_SET_CONTINUE_MSG_NUM(0x3B57); /* Can't play on GBA */ + mMsg_SET_FORCENEXT(); + break; + default: + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + my_room->emu_info.request_flag = FALSE; + mMsg_SET_CANCELNORMALCONTINUE(); + mMsg_UNSET_LOCKCONTINUE(); + mMsg_SET_FORCENEXT(); + break; + } + } +} + +static void aMR_MsgInitQqqEmulatorMemory2(ACTOR* actorx) { + mChoice_c* choice_win = mChoice_Get_base_window_p(); + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + u8 cancel_string[mChoice_CHOICE_STRING_LEN]; + + mChoice_Load_ChoseStringFromRom(choice_win, cancel_string, 0x1AB, NULL); /* No thanks. */ + + // clang-format off + mChoice_Set_choice_data(choice_win, + aMR_GetNameString(my_room, 0), mChoice_CHOICE_STRING_LEN, + aMR_GetNameString(my_room, 1), mChoice_CHOICE_STRING_LEN, + cancel_string, mChoice_CHOICE_STRING_LEN, + NULL, mChoice_CHOICE_STRING_LEN, + NULL, mChoice_CHOICE_STRING_LEN, + NULL, mChoice_CHOICE_STRING_LEN); + // clang-format on +} + +static void aMR_MsgControlQqqEmulatorMemory2(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + int choice_no = mChoice_GET_CHOSENUM(); + + mChoice_NO_B_CLOSE_SET(); + if (choice_no != -1) { + switch (choice_no) { + case mChoice_CHOICE0: + my_room->emu_info.rom_no = 0; + my_room->requested_msg_type = aMR_MSG_STATE_EXPLAIN_EMULATOR_MEMORY; + aMR_SetEmulatorStartMessage(actorx, FALSE); + break; + case mChoice_CHOICE1: + my_room->emu_info.rom_no = -1; + my_room->requested_msg_type = aMR_MSG_STATE_EXPLAIN_EMULATOR_MEMORY; + aMR_SetEmulatorStartMessage(actorx, FALSE); + break; + default: + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + my_room->emu_info.request_flag = FALSE; + mMsg_SET_CANCELNORMALCONTINUE(); + mMsg_UNSET_LOCKCONTINUE(); + mMsg_SET_FORCENEXT(); + break; + } + } +} + +static void aMR_MsgInitQqqEmulatorMemoryOver3(ACTOR* actorx) { + mChoice_c* choice_win = mChoice_Get_base_window_p(); + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + static u8 cancel_string[mChoice_CHOICE_STRING_LEN]; + static u8 else_string[mChoice_CHOICE_STRING_LEN]; + + mChoice_Load_ChoseStringFromRom(choice_win, cancel_string, 0x1AB, NULL); /* No thanks. */ + mChoice_Load_ChoseStringFromRom(choice_win, else_string, 0x235, NULL); /* Something else... */ + + // clang-format off + mChoice_Set_choice_data(choice_win, + aMR_GetNameString(my_room, 0), mChoice_CHOICE_STRING_LEN, + aMR_GetNameString(my_room, 1), mChoice_CHOICE_STRING_LEN, + else_string, mChoice_CHOICE_STRING_LEN, + cancel_string, mChoice_CHOICE_STRING_LEN, + NULL, mChoice_CHOICE_STRING_LEN, + NULL, mChoice_CHOICE_STRING_LEN); + // clang-format on +} + +static void aMR_MsgControlQqqEmulatorMemoryOver3(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + int choice_no = mChoice_GET_CHOSENUM(); + + mChoice_NO_B_CLOSE_SET(); + if (choice_no != -1) { + switch (choice_no) { + case mChoice_CHOICE0: + my_room->emu_info.rom_no = 0; + my_room->requested_msg_type = aMR_MSG_STATE_EXPLAIN_EMULATOR_MEMORY; + aMR_SetEmulatorStartMessage(actorx, FALSE); + break; + case mChoice_CHOICE1: + my_room->emu_info.rom_no = -1; + my_room->requested_msg_type = aMR_MSG_STATE_EXPLAIN_EMULATOR_MEMORY; + aMR_SetEmulatorStartMessage(actorx, FALSE); + break; + case mChoice_CHOICE2: + aMR_ReportDisplayMemoryGameSelectCount(my_room, 2); + if ((my_room->emu_info.card_famicom_count - my_room->emu_info.memory_game_select) >= 2 || + (my_room->emu_info.card_famicom_count - my_room->emu_info.memory_game_select) == 0) { + my_room->requested_msg_type = aMR_MSG_STATE_QQQ_REPEAT_DISPLAY2; + } else { + my_room->requested_msg_type = aMR_MSG_STATE_QQQ_REPEAT_DISPLAY1; + } + mMsg_SET_CONTINUE_MSG_NUM(0x3069); + mMsg_UNSET_LOCKCONTINUE(); + mMsg_SET_FORCENEXT(); + break; + default: + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + my_room->emu_info.request_flag = FALSE; + mMsg_SET_CANCELNORMALCONTINUE(); + mMsg_UNSET_LOCKCONTINUE(); + mMsg_SET_FORCENEXT(); + break; + } + } +} + +static void aMR_MsgInitQqqRepeatDisplay1(ACTOR* actorx) { + mChoice_c* choice_win = mChoice_Get_base_window_p(); + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + static u8 cancel_string[mChoice_CHOICE_STRING_LEN]; + static u8 else_string[mChoice_CHOICE_STRING_LEN]; + + switch (mChoice_check_main_index(choice_win)) { + case mChoice_MAIN_HIDE: + mChoice_Load_ChoseStringFromRom(choice_win, cancel_string, 0x1AB, NULL); /* No thanks. */ + mChoice_Load_ChoseStringFromRom(choice_win, else_string, 0x235, NULL); /* Something else... */ + + // clang-format off + mChoice_Set_choice_data(choice_win, + aMR_GetNameString(my_room, my_room->emu_info.memory_game_select), mChoice_CHOICE_STRING_LEN, + else_string, mChoice_CHOICE_STRING_LEN, + cancel_string, mChoice_CHOICE_STRING_LEN, + NULL, mChoice_CHOICE_STRING_LEN, + NULL, mChoice_CHOICE_STRING_LEN, + NULL, mChoice_CHOICE_STRING_LEN); + // clang-format on + break; + } +} + +static void aMR_MsgControlQqqRepeatDisplay1(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + int choice_no; + + aMR_MsgInitQqqRepeatDisplay1(actorx); + choice_no = mChoice_GET_CHOSENUM(); + mChoice_NO_B_CLOSE_SET(); + if (choice_no != -1) { + switch (choice_no) { + case mChoice_CHOICE0: + aMR_SetMemoryCardGameIndex(my_room, 0); + my_room->requested_msg_type = aMR_MSG_STATE_EXPLAIN_EMULATOR_MEMORY; + aMR_SetEmulatorStartMessage(actorx, FALSE); + aMR_ReportDisplayMemoryGameSelectCount(my_room, 1); + break; + case mChoice_CHOICE1: + aMR_ReportDisplayMemoryGameSelectCount(my_room, 1); + if ((my_room->emu_info.card_famicom_count - my_room->emu_info.memory_game_select) >= 2 || + (my_room->emu_info.card_famicom_count - my_room->emu_info.memory_game_select) == 0) { + my_room->requested_msg_type = aMR_MSG_STATE_QQQ_REPEAT_DISPLAY2; + } else if (my_room->msg_type == aMR_MSG_STATE_QQQ_REPEAT_DISPLAY1) { + my_room->requested_msg_type = aMR_MSG_STATE_QQQ_REPEAT_DISPLAY1_2; + } else { + my_room->requested_msg_type = aMR_MSG_STATE_QQQ_REPEAT_DISPLAY1; + } + mMsg_SET_CONTINUE_MSG_NUM(0x3069); + mMsg_UNSET_LOCKCONTINUE(); + mMsg_SET_FORCENEXT(); + break; + default: + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + my_room->emu_info.request_flag = FALSE; + mMsg_SET_CANCELNORMALCONTINUE(); + mMsg_UNSET_LOCKCONTINUE(); + mMsg_SET_FORCENEXT(); + break; + } + } +} + +static void aMR_MsgInitQqqRepeatDisplay2(ACTOR* actorx) { + mChoice_c* choice_win = mChoice_Get_base_window_p(); + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + static u8 cancel_string[mChoice_CHOICE_STRING_LEN]; + static u8 else_string[mChoice_CHOICE_STRING_LEN]; + + switch (mChoice_check_main_index(choice_win)) { + case mChoice_MAIN_HIDE: + mChoice_Load_ChoseStringFromRom(choice_win, cancel_string, 0x1AB, NULL); /* No thanks. */ + mChoice_Load_ChoseStringFromRom(choice_win, else_string, 0x235, NULL); /* Something else... */ + + // clang-format off + mChoice_Set_choice_data(choice_win, + aMR_GetNameString(my_room, my_room->emu_info.memory_game_select), mChoice_CHOICE_STRING_LEN, + aMR_GetNameString(my_room, my_room->emu_info.memory_game_select + 1), mChoice_CHOICE_STRING_LEN, + else_string, mChoice_CHOICE_STRING_LEN, + cancel_string, mChoice_CHOICE_STRING_LEN, + NULL, mChoice_CHOICE_STRING_LEN, + NULL, mChoice_CHOICE_STRING_LEN); + // clang-format on + break; + } +} + +static void aMR_MsgControlQqqRepeatDisplay2(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + int choice_no; + + aMR_MsgInitQqqRepeatDisplay2(actorx); + choice_no = mChoice_GET_CHOSENUM(); + mChoice_NO_B_CLOSE_SET(); + if (choice_no != -1) { + switch (choice_no) { + case mChoice_CHOICE0: + aMR_SetMemoryCardGameIndex(my_room, 0); + my_room->requested_msg_type = aMR_MSG_STATE_EXPLAIN_EMULATOR_MEMORY; + aMR_SetEmulatorStartMessage(actorx, FALSE); + break; + case mChoice_CHOICE1: + aMR_SetMemoryCardGameIndex(my_room, 1); + my_room->requested_msg_type = aMR_MSG_STATE_EXPLAIN_EMULATOR_MEMORY; + aMR_SetEmulatorStartMessage(actorx, FALSE); + break; + case mChoice_CHOICE2: + aMR_ReportDisplayMemoryGameSelectCount(my_room, 2); + if ((my_room->emu_info.card_famicom_count - my_room->emu_info.memory_game_select) >= 2 || + (my_room->emu_info.card_famicom_count - my_room->emu_info.memory_game_select) == 0) { + if (my_room->msg_type == aMR_MSG_STATE_QQQ_REPEAT_DISPLAY2) { + my_room->requested_msg_type = aMR_MSG_STATE_QQQ_REPEAT_DISPLAY2_2; + } else { + my_room->requested_msg_type = aMR_MSG_STATE_QQQ_REPEAT_DISPLAY2; + } + } else { + my_room->requested_msg_type = aMR_MSG_STATE_QQQ_REPEAT_DISPLAY1; + } + mMsg_SET_CONTINUE_MSG_NUM(0x3069); + mMsg_UNSET_LOCKCONTINUE(); + mMsg_SET_FORCENEXT(); + break; + default: + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + my_room->emu_info.request_flag = FALSE; + mMsg_SET_CANCELNORMALCONTINUE(); + mMsg_UNSET_LOCKCONTINUE(); + mMsg_SET_FORCENEXT(); + break; + } + } +} + +static void aMR_MsgInitExplainEmulatorMemory(ACTOR* actorx) { + // nothing +} + +static void aMR_MsgControlExplainEmulatorMemory(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + if (mMsg_CHECK_MAINDISAPPEAR()) { + my_room->emu_info.explaination_given_flag = TRUE; + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + } +} + +static void aMR_MsgInitNoPackNoData(ACTOR* actorx) { + aMR_SetSlotString(); +} + +static void aMR_MsgControlNoPackNoData(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + if (mMsg_CHECK_MAINDISAPPEAR()) { + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + mMsg_SET_CANCELNORMALCONTINUE(); + mMsg_UNSET_LOCKCONTINUE(); + my_room->room_msg_flag = FALSE; + } +} + +static void aMR_MsgInitWaitFamicomBatu(ACTOR* actorx) { + // nothing +} + +static void aMR_MsgControlWaitFamicomBatu(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + if (mMsg_CHECK_MAINDISAPPEAR() || mMsg_CHECK_MAINHIDE()) { + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + my_room->emu_info.request_flag = FALSE; + } +} + +static void aMR_MsgInitSaveFamicom(ACTOR* actorx) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + my_room->emu_info.save_msg_timer = 240; + my_room->emu_info.external_rom = (Common_Get(my_room_message_control_flags >> 3) & 1) ^ 1; + Common_Get(my_room_message_control_flags) &= ~(1 << 3); + Common_Get(my_room_message_control_flags) &= ~(1 << 4); + mMsg_SET_LOCKCONTINUE(); + aMR_SetSlotString(); +} + +static void aMR_MsgControlSaveFamicom(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + if (my_room->emu_info.save_msg_timer > 0) { + my_room->emu_info.save_msg_timer--; + } else { + my_room->emu_info.save_msg_timer = 0; + } + + if (my_room->emu_info.save_msg_timer == 0 && mMsg_CHECK_MAINNORMALCONTINUE()) { + int save_res; + + if (my_room->emu_info.external_rom == FALSE) { + save_res = famicom_internal_data_save(); + } else { + save_res = famicom_external_data_save(); + } + + aMR_SetSlotString(); + switch (save_res) { + case FAMICOM_RESULT_OK: + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + mMsg_UNSET_LOCKCONTINUE(); + mMsg_SET_FORCENEXT(); + mMsg_REQUEST_MAIN_DISAPPEAR(); + break; + case FAMICOM_RESULT_NOSPACE: + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + mMsg_SET_CONTINUE_MSG_NUM(0x2B6C); + mMsg_UNSET_LOCKCONTINUE(); + mMsg_SET_FORCENEXT(); + break; + case FAMICOM_RESULT_NOENTRY: + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + mMsg_SET_CONTINUE_MSG_NUM(0x2B6D); + mMsg_UNSET_LOCKCONTINUE(); + mMsg_SET_FORCENEXT(); + break; + case FAMICOM_RESULT_BROKEN: + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + mMsg_SET_CONTINUE_MSG_NUM(0x2B6E); + mMsg_UNSET_LOCKCONTINUE(); + mMsg_SET_FORCENEXT(); + break; + case FAMICOM_RESULT_WRONGDEVICE: + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + mMsg_SET_CONTINUE_MSG_NUM(0x2B6F); + mMsg_UNSET_LOCKCONTINUE(); + mMsg_SET_FORCENEXT(); + break; + case FAMICOM_RESULT_WRONGENCODING: + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + mMsg_SET_CONTINUE_MSG_NUM(0x2B70); + mMsg_UNSET_LOCKCONTINUE(); + mMsg_SET_FORCENEXT(); + break; + case FAMICOM_RESULT_NOCARD: + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + mMsg_SET_FREE_STR(mMsg_FREE_STR0, Save_Get(land_info).name, LAND_NAME_SIZE); + mMsg_SET_CONTINUE_MSG_NUM(0x2B71); + mMsg_UNSET_LOCKCONTINUE(); + mMsg_SET_FORCENEXT(); + break; + case FAMICOM_RESULT_NOFILE: + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + mMsg_SET_CONTINUE_MSG_NUM(0x3B56); + mMsg_UNSET_LOCKCONTINUE(); + mMsg_SET_FORCENEXT(); + break; + default: + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + + if (my_room->emu_info.external_rom == TRUE) { + mMsg_SET_CONTINUE_MSG_NUM(0x3072); + } else { + mMsg_SET_CONTINUE_MSG_NUM(0x3072); + } + + mMsg_UNSET_LOCKCONTINUE(); + mMsg_SET_FORCENEXT(); + break; + } + + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + my_room->room_msg_flag = FALSE; + } +} + +static void aMR_MsgInitHitokoto(ACTOR* actorx) { + // nothing +} + +static void aMR_MsgControlHitokoto(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + if (mMsg_CHECK_MAINDISAPPEAR()) { + my_room->requested_msg_type = aMR_MSG_STATE_NONE; + my_room->state = 0; + } +} + +typedef void (*aMR_MSG_INIT_PROC)(ACTOR*); +typedef void (*aMR_MSG_CTRL_PROC)(ACTOR*, GAME*); + +// clang-format off +static aMR_MSG_INIT_PROC msg_init_table[aMR_MSG_STATE_NUM] = { + &aMR_NoMsgInit, + &aMR_NoMsgInit, + &aMR_NoMsgInit, + &aMR_MsgInitOwnerExistItem, + &aMR_MsgInitOwnerExistItem, + &aMR_MsgInitOwnerWhichPutOut, + &aMR_MsgInitOwnerWhichPutOut, + &aMR_MsgInitOwnerWhichPutOut, + &aMR_MsgInitOwnerWaitWhichPutOut, + &aMR_NoMsgInit, + &aMR_MsgInitOwnerExistItem, + &aMR_MsgInitOwnerExistItem, + &aMR_MsgInitOwnerExistItem, + &aMR_MsgInitFullPlayerItem, + &aMR_MsgInitOwnerExistItem, + &aMR_MsgInitOwnerExistItem, + &aMR_NoMsgInit, + &aMR_MsgInitRequestCloseFtr, + &aMR_NoMsgInit, + &aMR_NoMsgInit, + &aMR_NoMsgInit, + &aMR_MsgInitOwnerExistItem, + &aMR_MsgInitOwnerExistItem, + &aMR_NoMsgInit, + &aMR_NoMsgInit, + &aMR_MsgInitOwnerExistMD, + &aMR_MsgInitOwnerExistMD, + &aMR_NoMsgInit, + &aMR_MsgInitOwnerExistItem, + &aMR_MsgInitOwnerExistItem, + &aMR_MsgInitOwnerExistItem, + &aMR_MsgInitOwnerExistItem, + &aMR_MsgInitOwnerExistItem, + &aMR_MsgInitOwnerExistItem, + &aMR_NoMsgInit, + &aMR_MsgInitRequestCloseMD, + &aMR_NoMsgInit, + &aMR_NoMsgInit, + &aMR_MsgInitOwnerExistItem, + &aMR_MsgInitOwnerExistItem, + &aMR_MsgInitQqqEmulator, + &aMR_MsgInitExplainEmulator, + &aMR_MsgInitQqqEmulatorMemory1, + &aMR_MsgInitExplainEmulatorMemory, + &aMR_MsgInitQqqEmulatorMemory2, + &aMR_MsgInitQqqEmulatorMemoryOver3, + &aMR_MsgInitQqqRepeatDisplay1, + &aMR_MsgInitQqqRepeatDisplay1, + &aMR_MsgInitQqqRepeatDisplay2, + &aMR_MsgInitQqqRepeatDisplay2, + &aMR_MsgInitNoPackNoData, + &aMR_MsgInitWarningCannotMakeSaveFile, + &aMR_MsgInitNoPackNoData, + &aMR_MsgInitNoPackNoData, + &aMR_MsgInitHitokoto, + &aMR_MsgInitHitokoto, + &aMR_MsgInitHitokoto, + &aMR_MsgInitSaveFamicom, + &aMR_MsgInitWaitFamicomBatu, + &aMR_MsgInitPrepareCommunication, + &aMR_MsgInitNotConnectAgb, + &aMR_MsgInitCheckAgbProgram, + &aMR_MsgInitDeleteAgbProgramQ, + &aMR_MsgInitStartEmuDownLoad, + &aMR_MsgInitRecheckAgbConnect, +}; +// clang-format on + +// clang-format off +static aMR_MSG_CTRL_PROC msg_ctrl_table[aMR_MSG_STATE_NUM] = { + &aMR_NoMsgControl, + &aMR_NoMsgControl, + &aMR_MsgControlOwnerNoItem, + &aMR_MsgControlOwnerExistItem, + &aMR_MsgControlOwnerExistItem_ItemCount2, + &aMR_MsgControlOwnerWhichPutOut, + &aMR_MsgControlOwnerWhichPutOut, + &aMR_MsgControlOwnerWhichPutOut, + &aMR_MsgControlOwnerWaitWhichPutOut, + &aMR_MsgControlOtherNoItem, + &aMR_MsgControlOtherExistItem, + &aMR_MsgControlOtherExistItem, + &aMR_MsgControlOtherExistItem, + &aMR_MsgControlFullPlayerItem, + &aMR_MsgControlOpenSubmenu, + &aMR_MsgControlItemPutIn, + &aMR_MsgControlWaitCloseFtr, + &aMR_MsgControlRequestCloseFtr, + &aMR_NoMsgControl, + &aMR_MsgControlCanNotClean, + &aMR_MsgControlCanNotClean, + &aMR_MsgControlOpenSetItemSubmenu, + &aMR_MsgControlItemSetSubmenu, + &aMR_NoMsgControl, + &aMR_MsgControlOwnerNoMD, + &aMR_MsgControlOwnerExistMD, + &aMR_MsgControlOwnerExistMD, + &aMR_MsgControlOtherNoMD, + &aMR_MsgControlOtherExistMD, + &aMR_MsgControlFullPlayerMD, + &aMR_MsgControlOpenMDSubmenu, + &aMR_MsgControlMDPutIn, + &aMR_MsgControlOpenMusicBox, + &aMR_MsgControlMusicBoxMDPutIn, + &aMR_MsgControlWaitCloseMD, + &aMR_MsgControlRequestCloseMD, + &aMR_NoMsgControl, + &aMR_MsgControlCanNotMDClean, + &aMR_MsgControlOpenExchangeMDSubmenu, + &aMR_MsgControlMDExchangeSubmenu, + &aMR_MsgControlQqqEmulator, + &aMR_MsgControlExplainEmulator, + &aMR_MsgControlQqqEmulatorMemory1, + &aMR_MsgControlExplainEmulatorMemory, + &aMR_MsgControlQqqEmulatorMemory2, + &aMR_MsgControlQqqEmulatorMemoryOver3, + &aMR_MsgControlQqqRepeatDisplay1, + &aMR_MsgControlQqqRepeatDisplay1, + &aMR_MsgControlQqqRepeatDisplay2, + &aMR_MsgControlQqqRepeatDisplay2, + &aMR_MsgControlNoPackNoData, + &aMR_MsgControlWarningCannotMakeSaveFile, + &aMR_MsgControlNoPackNoData, + &aMR_MsgControlNoPackNoData, + &aMR_MsgControlHitokoto, + &aMR_MsgControlHitokoto, + &aMR_MsgControlHitokoto, + &aMR_MsgControlSaveFamicom, + &aMR_MsgControlWaitFamicomBatu, + &aMR_MsgControlPrepareCommunication, + &aMR_MsgControlNotConnectAgb, + &aMR_MsgControlCheckAgbProgram, + &aMR_MsgControlDeleteAgbProgramQ, + &aMR_MsgControlStartEmuDownLoad, + &aMR_MsgControlRecheckAgbConnect, +}; +// clang-format on + +#define aMR_NO_MSG (-1) + +// clang-format off +static int aMR_msg_no_table[aMR_MSG_STATE_NUM] = { + aMR_NO_MSG, + aMR_NO_MSG, + 0x0A0A, + 0x0A0B, + 0x2F1A, + 0x2F1B, + 0x2F1E, + aMR_NO_MSG, + aMR_NO_MSG, + 0x0A0C, + 0x0A0D, + 0x2F1C, + 0x2F1D, + aMR_NO_MSG, + aMR_NO_MSG, + aMR_NO_MSG, + aMR_NO_MSG, + aMR_NO_MSG, + aMR_NO_MSG, + 0x2F1F, + 0x2F1F, + aMR_NO_MSG, + aMR_NO_MSG, + aMR_NO_MSG, + 0x10B7, + 0x10BE, + 0x10B8, + 0x10B9, + 0x10BA, + aMR_NO_MSG, + aMR_NO_MSG, + aMR_NO_MSG, + aMR_NO_MSG, + aMR_NO_MSG, + aMR_NO_MSG, + aMR_NO_MSG, + aMR_NO_MSG, + 0x10BC, + aMR_NO_MSG, + aMR_NO_MSG, + 0x2B72, + aMR_NO_MSG, + 0x2B72, + aMR_NO_MSG, + 0x3068, + 0x3068, + aMR_NO_MSG, + aMR_NO_MSG, + aMR_NO_MSG, + aMR_NO_MSG, + 0x2B69, + aMR_NO_MSG, + 0x306C, + 0x306B, + 0x3A8A, + 0x3AF1, + 0x3B58, + 0x2B6B, + aMR_NO_MSG, + aMR_NO_MSG, + aMR_NO_MSG, + aMR_NO_MSG, + aMR_NO_MSG, + aMR_NO_MSG, + aMR_NO_MSG, +}; +// clang-format on + +// clang-format off +static int aMR_none_talk_proc[aMR_MSG_STATE_NUM] = { + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + FALSE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, +}; +// clang-format on + +// clang-format off +static int aMR_force_talk_flag[aMR_MSG_STATE_NUM] = { + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, +}; +// clang-format on + +// clang-format off +static int aMR_window_se_flag[aMR_MSG_STATE_NUM] = { + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, + TRUE, +}; +// clang-format on + +static rgba_t aMR_window_color = { 255, 255, 20, 255 }; + +static int aMR_GetMessageNum(s16 msg_state, MY_ROOM_ACTOR* my_room) { + FTR_ACTOR* ftr_actor = &l_aMR_work.ftr_actor_list[my_room->demo_ftrID]; + if (msg_state == aMR_MSG_STATE_OTHER_NO_ITEM) { + if (Save_Get(scene_no) == SCENE_NPC_HOUSE || Save_Get(scene_no) == SCENE_COTTAGE_NPC) { + return 0x2988 + ((ftr_actor->name + my_room->demo_ftrID) & 0xF); + } + } + + return aMR_msg_no_table[msg_state]; +} + +static void aMR_speak_set(ACTOR* actorx) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + mDemo_Set_msg_num(aMR_GetMessageNum(my_room->msg_type, my_room)); + mDemo_Set_talk_display_name(FALSE); + mDemo_Set_camera(CAMERA2_PROCESS_NORMAL); + mDemo_Set_ListenAble(); + mDemo_Set_talk_window_color(&aMR_window_color); + mMsg_SET_CONTINUE_MSG_NUM(-1); +} + +static void aMR_report_set(ACTOR* actorx) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + + mDemo_Set_msg_num(aMR_GetMessageNum(my_room->msg_type, my_room)); + mDemo_Set_ListenAble(); + mDemo_Set_use_zoom_sound(aMR_window_se_flag[my_room->msg_type] & 1); + mDemo_Set_talk_window_color(&aMR_window_color); + mMsg_SET_CONTINUE_MSG_NUM(-1); +} + +static void aMR_MessageControl(ACTOR* actorx, GAME* game) { + MY_ROOM_ACTOR* my_room = (MY_ROOM_ACTOR*)actorx; + int demo_type; + + if (aMR_force_talk_flag[my_room->requested_msg_type]) { + demo_type = mDemo_TYPE_SPEAK; + } else { + demo_type = mDemo_TYPE_REPORT; + } + + if (my_room->requested_msg_type != my_room->msg_type && my_room->emu_info.explaination_given_flag == FALSE) { + if (aMR_msg_no_table[my_room->requested_msg_type] != aMR_NO_MSG) { + if (mDemo_Check(demo_type, actorx) == FALSE && + mDemo_Request(demo_type, actorx, demo_type == mDemo_TYPE_SPEAK ? &aMR_speak_set : &aMR_report_set)) { + my_room->msg_type = my_room->requested_msg_type; + mChoice_NO_B_CLOSE_SET(); + (*msg_init_table[my_room->msg_type])(actorx); + mChoice_CLEAR_CHOSENUM(); + } + } else { + my_room->msg_type = my_room->requested_msg_type; + mChoice_NO_B_CLOSE_SET(); + (*msg_init_table[my_room->msg_type])(actorx); + mChoice_CLEAR_CHOSENUM(); + } + } + + if (aMR_force_talk_flag[my_room->msg_type]) { + demo_type = mDemo_TYPE_SPEAK; + } else { + demo_type = mDemo_TYPE_REPORT; + } + + if (mDemo_Check(demo_type, actorx)) { + (*msg_ctrl_table[my_room->msg_type])(actorx, game); + } else if (aMR_none_talk_proc[my_room->msg_type] == TRUE) { + (*msg_ctrl_table[my_room->msg_type])(actorx, game); + } + + if (my_room->emu_info.request_flag == TRUE && my_room->emu_info.explaination_given_flag == TRUE && + mDemo_CheckDemo() == FALSE) { + int rom_no = my_room->emu_info.rom_no; + + if (rom_no <= 0) { + rom_no--; + } + + aMR_SaveWaltzTempo2(); + if (goto_emu_game(game, rom_no) == TRUE) { + mBGMPsComp_scene_mode(0x11); + mPlib_request_main_refuse_type1(game); + my_room->emu_info.request_flag = FALSE; + + if (rom_no < 0) { + Common_Get(my_room_message_control_flags) |= (1 << 4); + } else { + Common_Get(my_room_message_control_flags) |= (1 << 3); + } + } + } + + if ((Common_Get(my_room_message_control_flags) & (1 << 0))) { + my_room->requested_msg_type = aMR_MSG_STATE_NO_PACK_NO_DATA2; + my_room->room_msg_flag = TRUE; + Common_Get(my_room_message_control_flags) &= ~(1 << 0); + Common_Get(my_room_message_control_flags) &= ~(1 << 3); + Common_Get(my_room_message_control_flags) &= ~(1 << 4); + ; + } + + if ((Common_Get(my_room_message_control_flags) >> 3) & 1) { + my_room->requested_msg_type = aMR_MSG_STATE_SAVE_FAMICOM; + my_room->room_msg_flag = TRUE; + } else if ((Common_Get(my_room_message_control_flags) & (1 << 4))) { + my_room->requested_msg_type = aMR_MSG_STATE_SAVE_FAMICOM; + my_room->room_msg_flag = TRUE; + } +} diff --git a/src/famicom_emu.c b/src/famicom_emu.c index 69a1b030..7a184fc9 100644 --- a/src/famicom_emu.c +++ b/src/famicom_emu.c @@ -174,7 +174,7 @@ extern void famicom_emu_cleanup(GAME* game) { sAdo_SubGameEnd(); } -extern int famicom_gba_getImage(u32 rom_id, int* ptr) { +extern void* famicom_gba_getImage(u32 rom_id, size_t* size) { static char* names[] = { "cluclu", "usa_balloon", "donkey", "usa_jr_math", "pinball", "tennis", "usa_golf", NULL, "usa_baseball", NULL, "usa_donkey3", "donkeyjr", "soccer", "exbike", @@ -182,8 +182,7 @@ extern int famicom_gba_getImage(u32 rom_id, int* ptr) { }; char buf[256]; - u32 resource; - int block; + void* resource; char* rom; if (rom_id > 19) { @@ -197,9 +196,8 @@ extern int famicom_gba_getImage(u32 rom_id, int* ptr) { } else { sprintf(buf, "/FAMICOM/GBA/jb_%s.bin.szs", rom); resource = JC__JKRGetResource(buf); - if ((resource != 0) && (ptr != NULL)) { - block = JC__JKRGetMemBlockSize(0, resource); - *ptr = block; + if ((resource != NULL) && (size != NULL)) { + *size = JC__JKRGetMemBlockSize(0, resource); } } return resource; diff --git a/src/m_scene.c b/src/m_scene.c index d4e72a15..33e8ce51 100644 --- a/src/m_scene.c +++ b/src/m_scene.c @@ -529,7 +529,8 @@ extern int goto_next_scene(GAME_PLAY* play, int next_idx, int update_player_mode return res; } -extern int goto_emu_game(GAME_PLAY* play, u8 famicom_rom_id) { +extern int goto_emu_game(GAME* game, s16 famicom_rom_id) { + GAME_PLAY* play = (GAME_PLAY*)game; PLAYER_ACTOR* player = get_player_actor_withoutCheck(play); int res = FALSE;