Merge pull request #218 from Cuyler36/m_msg

Implement & link m_msg
This commit is contained in:
Cuyler36
2024-01-16 00:30:13 -05:00
committed by GitHub
27 changed files with 3996 additions and 84 deletions
+15
View File
@@ -147,6 +147,21 @@ config/rel.yml:
con_sentaku2_v:
addrs: [0x80650880, 0x806508C0]
type: vtx
# m_msg
msg/con_kaiwa2_w1_tex:
addrs: [0x80657360, 0x80657B60]
msg/con_kaiwa2_w2_tex:
addrs: [0x80657B60, 0x80658B60]
msg/con_kaiwa2_w3_tex:
addrs: [0x80658B60, 0x80659B60]
msg/con_kaiwa2_v:
addrs: [0x80659B60, 0x80659CE0]
type: vtx
msg/con_namefuti_TXT:
addrs: [0x80659D60, 0x8065A160]
msg/con_kaiwaname_v:
addrs: [0x8065A160, 0x8065A1A0]
type: vtx
# ac_boat_demo
aBTD_island_prg:
addrs: [0x8065FD4C, 0x80674F90]
+5
View File
@@ -188,6 +188,11 @@ m_melody.c:
.text: [0x803BF210, 0x803BF464]
.data: [0x806571D8, 0x80657200]
.bss: [0x81297E68, 0x81297E80]
m_msg.c:
.text: [0x803BF464, 0x803C6228]
.rodata: [0x806426E8, 0x80642938]
.data: [0x80657200, 0x8065A280]
.bss: [0x81297E80, 0x81298A00]
m_museum.c:
.text: [0x803C6228, 0x803C74C0]
.rodata: [0x80642938, 0x80642950]
+11
View File
@@ -15,6 +15,17 @@ typedef struct audio_tempo_beat_s {
/* 0x01 */ s8 beat;
} TempoBeat_c;
enum {
VOICE_STATUS_NORMAL,
VOICE_STATUS_ANGRY,
VOICE_STATUS_SAD,
VOICE_STATUS_FUN,
VOICE_STATUS_SLEEPY,
VOICE_STATUS_GLOOMY,
VOICE_STATUS_NUM
};
extern void sAdo_Calc_MicPosition_forTrig(f32* fcalc, u16* scalc, xyz_t* pos);
extern void sAdo_Calc_MicPosition_forLevel(f32* fcalc, u16* scalc, xyz_t* pos);
+4
View File
@@ -7,6 +7,10 @@
extern "C" {
#endif
#define VOICE_MODE_ANIMALESE 0
#define VOICE_MODE_CLICK 1
#define VOICE_MODE_SILENT 2
/* audio is monophonic */
#define MONO(id) (id | 0x1000)
#define SE_FLAG_15(id) (id | 0x8000)
+3 -5
View File
@@ -11,16 +11,14 @@ enum {
Config_SOUND_MODE_0,
Config_SOUND_MODE_1,
Config_SOUND_MODE_2,
Config_SOUND_MODE_3,
Config_SOUND_MODE_NUM
};
enum {
Config_VOICE_MODE_0,
Config_VOICE_MODE_1,
Config_VOICE_MODE_2,
Config_VOICE_MODE_3,
Config_VOICE_MODE_ANIMALESE,
Config_VOICE_MODE_CLICK,
Config_VOICE_MODE_SILENT,
Config_VOICE_MODE_NUM
};
+25 -1
View File
@@ -285,7 +285,7 @@ extern "C" {
enum {
mFont_CONT_CODE_BEGIN = 0,
mFont_CONT_CODE_LAST = mFont_CONT_CODE_BEGIN,
mFont_CONT_CODE_CONINTUE,
mFont_CONT_CODE_CONTINUE,
mFont_CONT_CODE_CLEAR,
mFont_CONT_CODE_CURSOR_SET_TIME,
mFont_CONT_CODE_BUTTON,
@@ -435,6 +435,30 @@ enum {
mFont_LineType_End
};
enum {
mFont_BGM_QUIET,
// TODO
mFont_BGM_NUM = 9
};
enum {
mFont_BGM_STOP_TYPE_NORMAL,
mFont_BGM_STOP_TYPE_QUICK,
mFont_BGM_STOP_TYPE_RESETTI,
mFont_BGM_STOP_TYPE_NUM
};
enum {
mFont_SE_0,
// TODO
mFont_SE_NUM = 7
};
#define mFont_CHAR_FLAG_CUT 1
#define mFont_CHAR_FLAG_USE_POLY 2
#define mFont_CHAR_FLAG_SCALE 4
+112 -69
View File
@@ -6,14 +6,19 @@
#include "m_choice.h"
#include "m_item_name.h"
#include "m_msg_data.h"
#include "audio.h"
#ifdef __cplusplus
extern "C" {
#endif
#define mMsg_MSG_BUF_MAX 1536
#define mMsg_MSG_BUF_SIZE 1600
#define mMsg_FREE_STRING_LEN 16
#define mMsg_MAIL_STRING_LEN 132
#define mMsg_MAX_LINE 4
#define mMsg_BUTTON_TURN_TIME 60.0f
enum {
mMsg_INDEX_HIDE,
@@ -69,8 +74,33 @@ enum {
mMsg_MAIL_STR_NUM
};
#define mMsg_STATUS_FLAG_ZOOMDOWN_LONG (1 << 11) /* When set, mMsg_sound_ZOOMDOWN_SHORT() sfx will not play */
enum {
mMsg_RESULT_VOID,
mMsg_RESULT_FALSE,
mMsg_RESULT_TRUE,
mMsg_RESULT_NUM
};
#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
typedef struct message_window_s mMsg_Window_c;
typedef struct message_data_s mMsg_Data_c;
@@ -86,7 +116,7 @@ typedef struct {
} mMsg_MainDisappearWait_Data_c;
typedef struct {
int saved_main_index;
int last_main_index;
} mMsg_MainWait_Data_c;
typedef union {
@@ -104,24 +134,24 @@ typedef struct {
} mMsg_Request_MainAppear_Data_c;
typedef struct {
int saved_main_index;
int init_flags;
int last_main_index;
u32 setup_flag;
} mMsg_Request_MainAppearWait_Data_c;
typedef struct {
int init_flags;
int wait_flag;
} mMsg_Request_MainCursor_Data_c;
typedef struct {
int init_flags;
int last_main_index;
} mMsg_Request_MainDisappearWait_Data_c;
typedef struct {
int init_flags;
int wait_flag;
} mMsg_Request_MainNormal_Data_c;
typedef struct {
int saved_main_index;
int last_main_index;
} mMsg_Request_MainWait_Data_c;
typedef union {
@@ -135,7 +165,7 @@ typedef union {
} mMsg_Request_Data_c;
typedef union {
u8 data[mMsg_MSG_BUF_SIZE];
u8 data[mMsg_MSG_BUF_SIZE] ATTRIBUTE_ALIGN(32);
u64 align;
} mMsg_MsgBuf_c;
@@ -158,18 +188,18 @@ struct message_window_s {
/* 0x018 */ f32 width;
/* 0x01C */ f32 height;
/* 0x020 */ ACTOR* talk_actor;
/* 0x020 */ ACTOR* client_actor_p;
/* 0x024 */ int show_actor_name;
/* 0x028 */ int actor_name_len;
/* 0x02C */ int nameplate_x;
/* 0x030 */ int nameplay_y;
/* 0x028 */ int client_name_len;
/* 0x02C */ f32 nameplate_x;
/* 0x030 */ f32 nameplate_y;
/* 0x034 */ int show_continue_button;
/* 0x038 */ u8 free_str[mMsg_FREE_STR_NUM][mMsg_FREE_STRING_LEN];
/* 0x178 */ int free_str_article[mMsg_FREE_STR_NUM];
/* 0x1C8 */ u8 item_str[mMsg_ITEM_STR_NUM][mMsg_FREE_STRING_LEN];
/* 0x1C8 */ u8 item_str[mMsg_ITEM_STR_NUM][mIN_ITEM_NAME_LEN];
/* 0x218 */ int item_str_article[mMsg_ITEM_STR_NUM];
/* 0x22C */ u8 mail_str[mMsg_MAIL_STR_NUM][mMsg_MAIL_STRING_LEN];
@@ -178,7 +208,7 @@ struct message_window_s {
/* 0x2B4 */ rgba_t name_background_color;
/* 0x2B8 */ rgba_t window_background_color;
/* 0x2BC */ rgba_t font_color[4];
/* 0x2BC */ rgba_t font_color[mMsg_MAX_LINE];
/* 0x2CC */ rgba_t continue_button_color;
@@ -189,7 +219,7 @@ struct message_window_s {
/* 0x2DC */ int _2DC;
/* 0x2E0 */ int text_lines;
/* 0x2E4 */ int current_line;
/* 0x2E4 */ int now_display_line;
/* 0x2E8 */ mChoice_c choice_window;
@@ -228,66 +258,79 @@ struct message_window_s {
/* 0x448 */ int continue_cancel_flag;
/* 0x44C */ int force_next;
/* 0x450 */ int lock_continue;
/* 0x454 */ s8 now_utter;
/* 0x454 */ u8 now_utter;
/* 0x458 */ mMsg_Main_Data_c main_data;
/* 0x460 */ mMsg_Request_Data_c request_data;
};
extern int mMsg_Get_Length_String(u8* buf, size_t buf_size);
extern mMsg_Window_c* mMsg_Get_base_window_p();
extern void mMsg_Set_free_str(mMsg_Window_c* msg, int free_str_no, u8* str, int str_size);
extern void mMsg_Set_free_str_art(mMsg_Window_c* msg, int free_str_no, u8* str, int str_size, int article_no);
extern void mMsg_Set_item_str_art(mMsg_Window_c* msg, int free_str_no, u8* str, int str_size, int article_no);
extern void mMsg_ct(GAME_PLAY*);
extern void mMsg_dt(GAME_PLAY*);
extern void mMsg_Main(GAME_PLAY*);
extern void mMsg_Draw(GAME_PLAY*);
extern void mMsg_debug_draw(gfxprint_t* gfxprint);
extern void mMsg_aram_init();
extern void mMsg_aram_init2();
extern int mMsg_Check_MainHide(mMsg_Window_c* msg);
extern void mMsg_Set_item_str(mMsg_Window_c* msg_win, int str_no, u8* item_str, int str_len);
extern void mMsg_Set_mail_str(mMsg_Window_c* msg_win, int str_no, u8* str, int str_len);
extern void mMsg_Set_continue_msg_num(mMsg_Window_c* msg_win, int continue_msg_num);
extern int mMsg_Check_MainNormalContinue(mMsg_Window_c* msg_win);
extern int mMsg_Check_main_wait(mMsg_Window_c* msg_win);
extern int mMsg_ChangeMsgData(mMsg_Window_c* msg_win, int msg_no);
extern void mMsg_Set_ForceNext(mMsg_Window_c* msg_win);
extern int mMsg_Check_not_series_main_wait(mMsg_Window_c* msg_win);
extern int mMsg_Check_MainDisappear(mMsg_Window_c* msg_win);
extern void mMsg_request_main_disappear_wait_type1(mMsg_Window_c* msg_win);
extern void mMsg_request_main_appear_wait_type1(mMsg_Window_c* msg_win);
extern void mMsg_Get_BodyParam(u32 table_rom_start, u32 data_rom_start, int entry_no, u32* data_addr, u32* data_size);
extern void mMsg_Set_LockContinue(mMsg_Window_c* msg_win);
extern void mMsg_Unset_LockContinue(mMsg_Window_c* msg_win);
extern int mMsg_Get_msg_num(mMsg_Window_c* msg_win);
extern int mMsg_Check_main_index(mMsg_Window_c* msg_win, int index);
extern int mMsg_request_main_appear(mMsg_Window_c* msg_win, ACTOR* other_actor, int display_name, rgba_t* window_color_p, int msg_no, int request_priority);
extern int mMsg_Check_main_hide(mMsg_Window_c* msg_win);
extern int mMsg_sound_voice_get_for_editor(int code);
extern int mMsg_sound_spec_change_voice(mMsg_Window_c* msg_win);
extern void mMsg_request_main_forceoff();
extern int mMsg_CopyPlayerName(u8* data, int idx, int max_size, int capitalize);
extern int mMsg_CopyTalkName(ACTOR* actor, u8* data, int idx, int max_size, int capitalize);
extern int mMsg_CopyTail(ACTOR* actor, u8* data, int idx, int max_size, int capitalize);
extern int mMsg_CopyYear(u8* data, int idx, int max_size);
extern int mMsg_CopyMonth(u8* data, int idx, int max_size);
extern int mMsg_CopyWeek(u8* data, int idx, int max_size);
extern int mMsg_CopyDay(u8* data, int idx, int max_size);
extern int mMsg_CopyHour(u8* data, int idx, int max_size);
extern int mMsg_CopyMin(u8* data, int idx, int max_size);
extern int mMsg_CopySec(u8* data, int idx, int max_size);
extern int mMsg_CopyFree(mMsg_Window_c* msg_win, int free_idx, u8* data, int idx, int max_size, int article, int capitalize);
extern int mMsg_CopyDetermination(mMsg_Window_c* msg_win, u8* data, int idx, int max_size);
extern int mMsg_CopyCountryName(u8* data, int idx, int max_size, int capitalize);
extern int mMsg_CopyRamdomNumber2(u8* data, int idx, int max_size);
extern int mMsg_CopyItem(mMsg_Window_c* msg_win, int item_idx, u8* data, int idx, int max_size, int article, int capitalize);
extern int mMsg_CopyMail(mMsg_Window_c* msg_win, int mail_idx, u8* data, int idx, int max_size);
extern int mMsg_CopyIslandName(u8* data, int idx, int max_size, int capitalize);
extern int mMsg_CopyAmPm(mMsg_Window_c* msg_win, u8* data, int idx, int max_size);
extern void mMsg_sound_set_voice_silent(mMsg_Window_c* msg_win, int update_voice_mode);
extern void mMsg_sound_unset_voice_silent(mMsg_Window_c* msg_win, int update_voice_mode);
extern void mMsg_ct(GAME* game);
extern void mMsg_dt(GAME* game);
extern void mMsg_debug_draw(gfxprint_t* gfxprint);
extern void mMsg_Main(GAME* game);
extern void mMsg_Draw(GAME* game);
extern mMsg_Window_c* mMsg_Get_base_window_p();
extern int mMsg_Check_request_priority(mMsg_Window_c* msg_p, int request_priority);
extern int mMsg_Check_main_index(mMsg_Window_c* msg_p, int main_index);
extern int mMsg_Check_main_wait(mMsg_Window_c* msg_p);
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_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);
extern int mMsg_request_main_appear_wait_type1(mMsg_Window_c* msg_p);
extern void mMsg_Set_free_str(mMsg_Window_c* msg_p, int free_str_no, u8* str, int str_len);
extern void mMsg_Set_free_str_cl(mMsg_Window_c* msg_p, int str_no, u8* str_p, int str_len, int cl_id);
extern void mMsg_Set_free_str_art(mMsg_Window_c* msg_p, int str_no, u8* str_p, int str_len, int article);
extern void mMsg_Set_free_str_cl_art(mMsg_Window_c* msg_p, int str_no, u8* str_p, int str_len, int cl_id, int article);
extern void mMsg_Set_item_str(mMsg_Window_c* msg_p, int item_str_no, u8* str, int str_len);
extern void mMsg_Set_item_str_art(mMsg_Window_c* msg_p, int item_str_no, u8* str, int str_len, int article);
/* @unused extern void mMsg_Get_free_str(mMsg_Window_c* msg_p, int free_str_no, u8* str?) */
/* @unused extern void mMsg_Get_item_str(mMsg_Window_c* msg_p, int item_str_no, u8* str?) */
extern void mMsg_Set_mail_str(mMsg_Window_c* msg_p, int mail_str_no, u8* str, int str_len);
extern void mMsg_Set_continue_msg_num(mMsg_Window_c* msg_p, int msg_no);
extern int mMsg_Get_msg_num(mMsg_Window_c* msg_p);
extern void mMsg_Get_BodyParam(u32 table_addr, u32 data_addr, int index, u32* addr, u32* size);
extern int mMsg_ChangeMsgData(mMsg_Window_c* msg_p, int index);
extern int mMsg_Check_NowUtter();
extern int mMsg_Get_Length_String(u8* str, int str_len);
extern int mMsg_Check_MainNormalContinue(mMsg_Window_c* msg_p);
extern int mMsg_Check_MainNormal(mMsg_Window_c* msg_p);
extern int mMsg_Check_MainHide(mMsg_Window_c* msg_p);
extern int mMsg_Check_MainDisappear(mMsg_Window_c* msg_p);
extern void mMsg_Set_CancelNormalContinue(mMsg_Window_c* msg_p);
extern void mMsg_Unset_CancelNormalContinue(mMsg_Window_c* msg_p);
extern void mMsg_Set_ForceNext(mMsg_Window_c* msg_p);
extern void mMsg_Unset_ForceNext(mMsg_Window_c* msg_p);
// extern int mMsg_Get_LockContinue(mMsg_Window_c* msg_p);
extern void mMsg_Set_LockContinue(mMsg_Window_c* msg_p);
extern void mMsg_Unset_LockContinue(mMsg_Window_c* msg_p);
extern void mMsg_Set_idling_req(mMsg_Window_c* msg_p);
extern int mMsg_Check_idling_now(mMsg_Window_c* msg_p);
extern int mMsg_MoveDataCut(u8* data, int dst_idx, int src_idx, int len, int space_flag);
extern int mMsg_CopyPlayerName(u8* data, int start_idx, int len, u32 capitalize);
extern int mMsg_CopyTalkName(ACTOR* actor_p, u8* data, int start_idx, int len, u32 capitalize);
extern int mMsg_CopyTail(ACTOR* actor_p, u8* data, int start_idx, int len, u32 capitalize);
extern int mMsg_CopyYear(u8* data, int start_idx, int len);
extern int mMsg_CopyMonth(u8* data, int start_idx, int len);
extern int mMsg_CopyWeek(u8* data, int start_idx, int len);
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_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_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_CopyMail(mMsg_Window_c* msg_p, int str_no, u8* data, int start_idx, int len, u32 capitalize);
#ifdef __cplusplus
}
+2
View File
@@ -12,6 +12,8 @@ extern "C" {
#define MSG_SANTA_WISH_CARPET 0x2B56
#define MSG_SANTA_WISH_CLOTH 0x2B57
#define MSG_MAX 0x3F91 /* Maximum message id */
#ifdef __cplusplus
}
#endif
+1 -2
View File
@@ -287,8 +287,7 @@ int aNRTC_talk_init(ACTOR* actor, GAME* game) {
break;
}
rtc->npc_class.talk_info.talk_request_proc = mActor_NONE_PROC1;
mMsg_Get_base_window_p();
mMsg_Set_idling_req();
mMsg_Set_idling_req(mMsg_Get_base_window_p());
return 1;
}
+1 -1
View File
@@ -37,7 +37,7 @@ static void mChoice_MainSetup_Disappear(mChoice_c* choice, GAME* game) {
if (choice->no_b_flag && choice->selected_choice_idx == (choice->data.choice_num - 1)) {
if (choice->no_close_flag) {
mChoice_sound_ZOOMDOWN_LONG();
mMsg_Get_base_window_p()->status_flags |= mMsg_STATUS_FLAG_ZOOMDOWN_LONG;
mMsg_Get_base_window_p()->status_flags |= mMsg_STATUS_FLAG_NO_ZOOMDOWN;
}
else {
mChoice_sound_ZOOMDOWN_SHORT();
+166
View File
@@ -0,0 +1,166 @@
#include "m_msg.h"
#include "main.h"
#include "m_font.h"
#include "m_string.h"
#include "m_handbill.h"
#include "m_common_data.h"
#include "jsyswrap.h"
#include "m_bgm.h"
#include "libforest/emu64/emu64_wrapper.h"
#include "sys_matrix.h"
static u32 Msg_table_rom_start = 0;
static u32 Msg_rom_start = 0;
static mMsg_Data_c mMsg_data;
static mMsg_Window_c mMsg_window;
typedef int (*mMsg_CONTROL_CODE_PROC)(mMsg_Window_c*, int*);
typedef void (*mMsg_MAIN_PROC)(mMsg_Window_c*, GAME*);
/* HACK - assetrip only sees top-level C file includes */
#ifdef MUST_MATCH
#ifndef __INTELLISENSE__
/* Force assetrip to detect these assets. They're used in a .c_inc file. */
FORCESTRIP static u8 __unused_msg0[] = {
#include "assets/msg/con_kaiwa2_w1_tex.inc"
};
FORCESTRIP static u8 __unused_msg1[] = {
#include "assets/msg/con_kaiwa2_w2_tex.inc"
};
FORCESTRIP static u8 __unused_msg2[] = {
#include "assets/msg/con_kaiwa2_w3_tex.inc"
};
FORCESTRIP static Vtx __unused_msg3[] = {
#include "assets/msg/con_kaiwa2_v.inc"
};
FORCESTRIP static u8 __unused_msg4[] = {
#include "assets/msg/con_namefuti_TXT.inc"
};
FORCESTRIP static Vtx __unused_msg5[] = {
#include "assets/msg/con_kaiwaname_v.inc"
};
#endif
#endif
static void mMsg_MainSetup_Window(mMsg_Window_c* msg_p, GAME* game);
#include "../src/m_msg_ctrl.c_inc"
static void mMsg_sound_MessageSpeedForce(f32 timer);
static void mMsg_sound_MessageStatus(u8 status);
#include "../src/m_msg_main.c_inc"
#include "../src/m_msg_sound.c_inc"
#include "../src/m_msg_hide.c_inc"
#include "../src/m_msg_appear.c_inc"
#include "../src/m_msg_normal.c_inc"
#include "../src/m_msg_cursol.c_inc"
#include "../src/m_msg_disappear.c_inc"
#include "../src/m_msg_appear_wait.c_inc"
#include "../src/m_msg_wait.c_inc"
#include "../src/m_msg_disappear_wait.c_inc"
#include "../src/m_msg_data.c_inc"
#include "../src/m_msg_draw_window.c_inc"
#include "../src/m_msg_draw_font.c_inc"
static void mMsg_MainSetup_Window(mMsg_Window_c* msg_p, GAME* game) {
static mMsg_MAIN_PROC proc[mMsg_INDEX_NUM] = {
&mMsg_MainSetup_Hide,
&mMsg_MainSetup_Appear,
&mMsg_MainSetup_Normal,
&mMsg_MainSetup_Cursol,
&mMsg_MainSetup_Disappear,
&mMsg_MainSetup_Appear_Wait,
&mMsg_MainSetup_Wait,
&mMsg_MainSetup_Disappear_wait
};
int idx = msg_p->requested_main_index;
if (idx >= 0) {
if (idx >= mMsg_INDEX_NUM || proc[idx] == NULL) {
return;
}
(*proc[idx])(msg_p, game);
}
}
static void mMsg_Main_Window(mMsg_Window_c* msg_p, GAME* game) {
static mMsg_MAIN_PROC proc[mMsg_INDEX_NUM] = {
&mMsg_Main_Hide,
&mMsg_Main_Appear,
&mMsg_Main_Normal,
&mMsg_Main_Cursol,
&mMsg_Main_Disappear,
&mMsg_Main_Appear_wait,
&mMsg_Main_Wait,
&mMsg_Main_Disappear_wait
};
int idx = msg_p->main_index;
if (idx >= 0) {
if (idx >= mMsg_INDEX_NUM || proc[idx] == NULL) {
return;
}
(*proc[idx])(msg_p, game);
}
}
static void mMsg_Draw_Window(mMsg_Window_c* msg_p, GAME* game) {
if (msg_p->draw_flag && msg_p->data_loaded) {
mFont_SetMatrix(game->graph, mFont_MODE_FONT);
mMsg_SetMatrix(msg_p, game, mFont_MODE_FONT);
mMsg_DrawWindowBody(msg_p, game, mFont_MODE_FONT);
mMsg_UnSetMatrix();
mFont_UnSetMatrix(game->graph, mFont_MODE_FONT);
if (msg_p->msg_data->data_loaded) {
mMsg_draw_font(msg_p, game);
}
mChoice_Draw(&msg_p->choice_window, game, mFont_MODE_FONT);
}
}
extern void mMsg_aram_init() {
mChoice_aram_init();
mString_aram_init();
mHandbill_aram_init();
}
extern void mMsg_aram_init2() {
Msg_table_rom_start = JW_GetAramAddress(RESOURCE_MESSAGE_TABLE);
Msg_rom_start = JW_GetAramAddress(RESOURCE_MESSAGE);
}
extern void mMsg_ct(GAME* game) {
mMsg_init(game);
mChoice_ct(&mMsg_window.choice_window, game);
}
extern void mMsg_dt(GAME* game) {
mChoice_dt(&mMsg_window.choice_window, game);
}
extern void mMsg_debug_draw(gfxprint_t* gfxprint) {
if (mMsg_window.msg_data != NULL) {
gfxprint_color(gfxprint, 245, 255, 250, 255);
gfxprint_locate8x8(gfxprint, 3, 6);
gfxprint_printf(gfxprint, "%5d", mMsg_window.msg_data->msg_no);
}
}
extern void mMsg_Main(GAME* game) {
mMsg_Main_Window(&mMsg_window, game);
mChoice_Main(&mMsg_window.choice_window, game);
}
extern void mMsg_Draw(GAME* game) {
mMsg_Draw_Window(&mMsg_window, game);
}
+93
View File
@@ -0,0 +1,93 @@
static int mMsg_Main_Appear_SetScale(mMsg_Window_c* msg_p, GAME* game) {
const f32 max = 18.0f;
if (msg_p->timer < max) {
f32 scale;
msg_p->timer += 1.0f;
scale = get_percent_forAccelBrake(msg_p->timer, 0.0f, max, 0.0f, 0.0f);
msg_p->window_scale = scale;
msg_p->text_scale = scale;
return FALSE;
}
else {
msg_p->window_scale = 1.0f;
msg_p->text_scale = 1.0f;
msg_p->timer = 0.0f;
return TRUE;
}
}
static void mMsg_request_main_index_fromAppear(mMsg_Window_c* msg_p, GAME* game, int scale_done_flag) {
if (scale_done_flag && mMsg_request_main_cursol(msg_p, FALSE, 5)) {
mMsg_SetTimer(msg_p, 20.0f);
}
}
static void mMsg_Main_Appear(mMsg_Window_c* msg_p, GAME* game) {
int scaling_done_flag = mMsg_Main_Appear_SetScale(msg_p, game);
mMsg_request_main_index_fromAppear(msg_p, game, scaling_done_flag);
mMsg_MainSetup_Window(msg_p, game);
}
static void mMsg_MainSetup_Appear(mMsg_Window_c* msg_p, GAME* game) {
mMsg_Request_MainAppear_Data_c* appear_data = &msg_p->request_data.request_main_appear;
int msg_no = appear_data->msg_no;
if (mMsg_LoadMsgData(msg_p->msg_data, msg_no, FALSE)) {
ACTOR* actor = appear_data->speaker_actor;
int show_name = appear_data->name_shown_flag;
mMsg_Set_client_actor_p(msg_p, actor, show_name);
msg_p->window_background_color = appear_data->window_color;
mMsg_sound_spec_change_voice(msg_p);
mMsg_sound_voice_mode(msg_p);
msg_p->main_index = mMsg_INDEX_APPEAR;
msg_p->draw_flag = TRUE;
msg_p->window_scale = 0.0f;
msg_p->text_scale = 0.0f;
msg_p->timer = 0.0f;
msg_p->show_continue_button = FALSE;
msg_p->requested_main_index = -1;
msg_p->requested_priority = 4;
msg_p->start_text_cursor_idx = 0;
msg_p->end_text_cursor_idx = 0;
if (msg_p->client_actor_p != NULL) {
switch (mNpc_GetNpcSex(msg_p->client_actor_p)) {
case mPr_SEX_MALE:
msg_p->name_background_color.r = 70;
msg_p->name_background_color.g = 245;
msg_p->name_background_color.b = 255;
msg_p->name_text_color.r = 0;
msg_p->name_text_color.g = 0;
msg_p->name_text_color.b = 15;
break;
case mPr_SEX_FEMALE:
msg_p->name_background_color.r = 235;
msg_p->name_background_color.g = 140;
msg_p->name_background_color.b = 210;
msg_p->name_text_color.r = 45;
msg_p->name_text_color.g = 0;
msg_p->name_text_color.b = 30;
break;
default:
msg_p->name_background_color.r = 185;
msg_p->name_background_color.g = 255;
msg_p->name_background_color.b = 0;
msg_p->name_text_color.r = 0;
msg_p->name_text_color.g = 30;
msg_p->name_text_color.b = 0;
break;
}
}
msg_p->data_loaded = TRUE;
emu64_refresh();
}
else {
msg_p->data_loaded = FALSE;
}
}
+47
View File
@@ -0,0 +1,47 @@
static void mMsg_request_main_index_fromAppear_wait(mMsg_Window_c* msg_p, GAME* game, int scaling_done_flag) {
if (scaling_done_flag) {
mMsg_MainAppearWait_Data_c* main_data = &msg_p->main_data.main_appear_wait;
int saved_main_index = main_data->saved_main_index;
if (saved_main_index == mMsg_INDEX_CURSOL) {
mMsg_request_main_cursol(msg_p, TRUE, 5);
}
else {
mMsg_request_main_normal(msg_p, TRUE, 5);
}
}
}
static void mMsg_Main_Appear_wait(mMsg_Window_c* msg_p, GAME* game) {
int scaling_finished;
if ((msg_p->status_flags & mMsg_STATUS_FLAG_NO_ZOOMUP) == FALSE) {
msg_p->status_flags |= mMsg_STATUS_FLAG_NO_ZOOMUP;
mMsg_sound_ZOOMUP();
mMsg_sound_spec_change_voice(msg_p);
mMsg_sound_voice_mode(msg_p);
}
scaling_finished = mMsg_Main_Appear_SetScale(msg_p, game);
mMsg_request_main_index_fromAppear_wait(msg_p, game, scaling_finished);
mMsg_MainSetup_Window(msg_p, game);
}
static void mMsg_MainSetup_Appear_Wait(mMsg_Window_c* msg_p, GAME* game) {
mMsg_Request_MainAppearWait_Data_c* request_data = &msg_p->request_data.request_main_appear_wait;
mMsg_MainAppearWait_Data_c* main_data = &msg_p->main_data.main_appear_wait;
if ((request_data->setup_flag & 1)) {
mMsg_Clear_CursolIndex(msg_p);
}
main_data->saved_main_index = request_data->last_main_index;
msg_p->main_index = mMsg_INDEX_APPEAR_WAIT;
msg_p->draw_flag = TRUE;
msg_p->window_scale = 0.0f;
msg_p->text_scale = 0.0f;
msg_p->timer = 0.0f;
msg_p->status_flags &= ~(mMsg_STATUS_FLAG_NOT_PAUSE_FRAME | mMsg_STATUS_FLAG_NO_ZOOMUP);
msg_p->requested_main_index = -1;
msg_p->requested_priority = 4;
}
+346
View File
@@ -0,0 +1,346 @@
extern mMsg_Window_c* mMsg_Get_base_window_p() {
return &mMsg_window;
}
extern int mMsg_Check_request_priority(mMsg_Window_c* msg_p, int request_priority) {
return request_priority > msg_p->requested_priority;
}
static int mMsg_Change_request_main_index(mMsg_Window_c* msg_p, int request_main_index, int request_priority) {
if (mMsg_Check_request_priority(msg_p, request_priority)) {
msg_p->requested_main_index = request_main_index;
msg_p->requested_priority = request_priority;
return TRUE;
}
return FALSE;
}
extern int mMsg_Check_main_index(mMsg_Window_c* msg_p, int main_index) {
return msg_p->main_index == main_index;
}
extern int mMsg_Check_main_wait(mMsg_Window_c* msg_p) {
return mMsg_Check_main_index(msg_p, mMsg_INDEX_WAIT);
}
extern int mMsg_Check_not_series_main_wait(mMsg_Window_c* msg_p) {
return !(
mMsg_Check_main_index(msg_p, mMsg_INDEX_WAIT) ||
mMsg_Check_main_index(msg_p, mMsg_INDEX_APPEAR_WAIT) ||
mMsg_Check_main_index(msg_p, mMsg_INDEX_DISAPPEAR_WAIT)
);
}
extern int mMsg_Check_main_hide(mMsg_Window_c* msg_p) {
return mMsg_Check_main_index(msg_p, mMsg_INDEX_HIDE);
}
static void mMsg_Set_client_actor_p(mMsg_Window_c* msg_p, ACTOR* client_actor_p, int show_name) {
if (client_actor_p != NULL) {
u8 name[ANIMAL_NAME_LEN];
f32 width;
f32 ofs_x;
int len;
msg_p->client_actor_p = client_actor_p;
msg_p->show_actor_name = show_name;
mNpc_GetNpcWorldName(name, client_actor_p);
len = mMsg_Get_Length_String(name, ANIMAL_NAME_LEN);
width = mFont_GetStringWidth(name, len, TRUE);
ofs_x = ((9.0f * (f32)ANIMAL_NAME_LEN) - width) * 0.5f;
msg_p->nameplate_x = 61.0f + ofs_x;
msg_p->nameplate_y = 64.0f;
msg_p->client_name_len = len;
}
else {
msg_p->client_actor_p = NULL;
msg_p->show_actor_name = FALSE;
}
}
extern int mMsg_request_main_forceoff() {
return mMsg_Change_request_main_index(mMsg_Get_base_window_p(), mMsg_INDEX_HIDE, 9);
}
extern int mMsg_request_main_disappear(mMsg_Window_c* msg_p) {
return mMsg_end_to_disappear(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) {
if (mMsg_Change_request_main_index(msg_p, mMsg_INDEX_APPEAR, request_priority)) {
mMsg_Request_MainAppear_Data_c* data = &msg_p->request_data.request_main_appear;
data->speaker_actor = client_actor_p;
data->name_shown_flag = show_name;
data->window_color = *window_color;
data->msg_no = msg_no;
return TRUE;
}
return FALSE;
}
static int mMsg_request_main_disappear_wait(mMsg_Window_c* msg_p, int last_main_index, int request_priority) {
if (mMsg_Change_request_main_index(msg_p, mMsg_INDEX_DISAPPEAR_WAIT, request_priority)) {
mMsg_Request_MainDisappearWait_Data_c* data = &msg_p->request_data.request_main_disappear_wait;
data->last_main_index = last_main_index;
return TRUE;
}
return FALSE;
}
static int mMsg_request_main_disappear_wait_sub(mMsg_Window_c* msg_p, int last_main_index) {
if (mChoice_check_main_index(mChoice_Get_base_window_p()) == mChoice_MAIN_HIDE) {
return mMsg_request_main_disappear_wait(msg_p, last_main_index, 5);
}
return FALSE;
}
extern int mMsg_request_main_disappear_wait_type1(mMsg_Window_c* msg_p) {
return mMsg_request_main_disappear_wait_sub(msg_p, msg_p->main_index);
}
extern int mMsg_request_main_disappear_wait_type2(mMsg_Window_c* msg_p) {
return mMsg_request_main_disappear_wait_sub(msg_p, mMsg_INDEX_NORMAL);
}
static int mMsg_request_main_wait(mMsg_Window_c* msg_p, int last_main_index, int request_priority) {
if (mMsg_Change_request_main_index(msg_p, mMsg_INDEX_WAIT, request_priority)) {
mMsg_Request_MainWait_Data_c* data = &msg_p->request_data.request_main_wait;
data->last_main_index = last_main_index;
return TRUE;
}
return FALSE;
}
static int mMsg_request_main_appear_wait(mMsg_Window_c* msg_p, int last_main_index, u32 setup_flag, int request_priority) {
if (mMsg_Change_request_main_index(msg_p, mMsg_INDEX_APPEAR_WAIT, request_priority)) {
mMsg_Request_MainAppearWait_Data_c* data = &msg_p->request_data.request_main_appear_wait;
data->last_main_index = last_main_index;
data->setup_flag = setup_flag;
return TRUE;
}
return FALSE;
}
extern int mMsg_request_main_appear_wait_type2(mMsg_Window_c* msg_p, int clear_flag) {
if (msg_p->main_index == mMsg_INDEX_WAIT) {
mMsg_MainWait_Data_c* data = &msg_p->main_data.main_wait;
int last_main_index = data->last_main_index;
u32 setup_flag = clear_flag ? TRUE : FALSE;
return mMsg_request_main_appear_wait(msg_p, last_main_index, setup_flag, 5);
}
return FALSE;
}
extern int mMsg_request_main_appear_wait_type1(mMsg_Window_c* msg_p) {
return mMsg_request_main_appear_wait_type2(msg_p, TRUE);
}
static int mMsg_request_main_normal(mMsg_Window_c* msg_p, int wait_flag, int request_priority) {
if (mMsg_Change_request_main_index(msg_p, mMsg_INDEX_NORMAL, request_priority)) {
mMsg_Request_MainNormal_Data_c* data = &msg_p->request_data.request_main_normal;
data->wait_flag = wait_flag;
return TRUE;
}
return FALSE;
}
static int mMsg_request_main_cursol(mMsg_Window_c* msg_p, int wait_flag, int request_priority) {
if (mMsg_Change_request_main_index(msg_p, mMsg_INDEX_CURSOL, request_priority)) {
mMsg_Request_MainCursor_Data_c* data = &msg_p->request_data.request_main_cursor;
data->wait_flag = wait_flag;
return TRUE;
}
return FALSE;
}
extern void mMsg_Set_free_str(mMsg_Window_c* msg_p, int free_str_no, u8* str, int str_len) {
if (free_str_no >= mMsg_FREE_STR0 && free_str_no < mMsg_FREE_STR_NUM && str != NULL) {
int i;
u8* free_str = msg_p->free_str[free_str_no];
if (str_len > mMsg_FREE_STRING_LEN) {
str_len = mMsg_FREE_STRING_LEN;
}
for (i = 0; i < mMsg_FREE_STRING_LEN; i++) {
if (i < str_len) {
free_str[i] = str[i];
}
else {
free_str[i] = CHAR_SPACE;
}
}
msg_p->free_str_article[free_str_no] = mIN_ARTICLE_NONE;
}
if (free_str_no == mMsg_FREE_STR1) {
msg_p->free_str_color_idx[0] = 0;
}
else if (free_str_no == mMsg_FREE_STR2) {
msg_p->free_str_color_idx[1] = 0;
}
else if (free_str_no == mMsg_FREE_STR5) {
msg_p->free_str_color_idx[2] = 0;
}
}
extern void mMsg_Set_free_str_cl(mMsg_Window_c* msg_p, int str_no, u8* str_p, int str_len, int cl_id) {
mMsg_Set_free_str_cl_art(msg_p, str_no, str_p, str_len, cl_id, mIN_ARTICLE_NONE);
}
extern void mMsg_Set_free_str_art(mMsg_Window_c* msg_p, int str_no, u8* str_p, int str_len, int article) {
mMsg_Set_free_str_cl_art(msg_p, str_no, str_p, str_len, 0, article);
}
extern void mMsg_Set_free_str_cl_art(mMsg_Window_c* msg_p, int str_no, u8* str_p, int str_len, int cl_id, int article) {
mMsg_Set_free_str(msg_p, str_no, str_p, str_len);
if (cl_id != 0) {
if (str_no == mMsg_FREE_STR1) {
msg_p->free_str_color_idx[0] = cl_id;
}
else if (str_no == mMsg_FREE_STR2) {
msg_p->free_str_color_idx[1] = cl_id;
}
else if (str_no == mMsg_FREE_STR5) {
msg_p->free_str_color_idx[2] = cl_id;
}
}
msg_p->free_str_article[str_no] = article;
}
extern void mMsg_Set_item_str(mMsg_Window_c* msg_p, int item_str_no, u8* str, int str_len) {
if (item_str_no >= mMsg_ITEM_STR0 && item_str_no < mMsg_ITEM_STR_NUM && str != NULL) {
int i;
u8* free_str = msg_p->item_str[item_str_no];
if (str_len > mIN_ITEM_NAME_LEN) {
str_len = mIN_ITEM_NAME_LEN;
}
for (i = 0; i < mIN_ITEM_NAME_LEN; i++) {
if (i < str_len) {
free_str[i] = str[i];
}
else {
free_str[i] = CHAR_SPACE;
}
}
msg_p->item_str_article[item_str_no] = mIN_ARTICLE_NONE;
}
}
extern void mMsg_Set_item_str_art(mMsg_Window_c* msg_p, int item_str_no, u8* str, int str_len, int article) {
mMsg_Set_item_str(msg_p, item_str_no, str, str_len);
msg_p->item_str_article[item_str_no] = article;
}
/* @unused extern void mMsg_Get_free_str(mMsg_Window_c* msg_p, int free_str_no, u8* str?) */
/* @unused extern void mMsg_Get_item_str(mMsg_Window_c* msg_p, int item_str_no, u8* str?) */
extern void mMsg_Set_mail_str(mMsg_Window_c* msg_p, int mail_str_no, u8* str, int str_len) {
if (mail_str_no >= mMsg_MAIL_STR0 && mail_str_no < mMsg_MAIL_STR_NUM && str != NULL) {
int src;
int dst;
u8* dst_p;
u8* src_p;
int rows;
int width;
if (str_len > mMsg_MAIL_STRING_LEN) {
str_len = mMsg_MAIL_STRING_LEN;
}
dst = 0;
dst_p = msg_p->mail_str[mail_str_no];
src_p = str;
rows = 0;
width = 0;
for (src = 0; src < str_len; src++) {
u8 c = *src_p++;
if (c == CHAR_NEW_LINE) {
rows++;
*dst_p++ = c;
dst++;
width = 0;
if (dst >= mMsg_MAIL_STRING_LEN || rows > 4) {
break;
}
}
else {
*dst_p++ = c;
dst++;
width += mFont_GetCodeWidth(c, TRUE);
if (dst >= mMsg_MAIL_STRING_LEN) {
break;
}
else if (width > 186) {
rows++;
*dst_p++ = CHAR_NEW_LINE;
dst++;
width = 0;
if (dst >= mMsg_MAIL_STRING_LEN || rows > 4) {
break;
}
}
}
}
for (dst; dst < mMsg_MAIL_STRING_LEN; dst++) {
*dst_p++ = CHAR_SPACE;
}
}
}
extern void mMsg_Set_continue_msg_num(mMsg_Window_c* msg_p, int msg_no) {
msg_p->continue_msg_no = msg_no;
}
extern int mMsg_Get_msg_num(mMsg_Window_c* msg_p) {
mMsg_Data_c* data_p = msg_p->msg_data;
if (msg_p->data_loaded && data_p->data_loaded) {
return data_p->msg_no;
}
return -1;
}
static int mMsg_Check_give_item() {
return Common_Get(clip).handOverItem_clip != NULL && Common_Get(clip).handOverItem_clip->master_actor != NULL;
}
static void mMsg_set_cursol_just(mMsg_Window_c* msg_p) {
msg_p->status_flags |= mMsg_STATUS_FLAG_CURSOL_JUST;
}
static void mMsg_unset_cursol_just(mMsg_Window_c* msg_p) {
msg_p->status_flags &= ~mMsg_STATUS_FLAG_CURSOL_JUST;
}
File diff suppressed because it is too large Load Diff
+97
View File
@@ -0,0 +1,97 @@
static u8 con_kaiwa2_w1_tex[] ATTRIBUTE_ALIGN(32) = {
#include "assets/msg/con_kaiwa2_w1_tex.inc"
};
static u8 con_kaiwa2_w2_tex[] ATTRIBUTE_ALIGN(32) = {
#include "assets/msg/con_kaiwa2_w2_tex.inc"
};
static u8 con_kaiwa2_w3_tex[] ATTRIBUTE_ALIGN(32) = {
#include "assets/msg/con_kaiwa2_w3_tex.inc"
};
static Vtx con_kaiwa2_v[] = {
#include "assets/msg/con_kaiwa2_v.inc"
};
static Gfx con_kaiwa2_modelT[] = {
gsSPTexture(0, 0, 0, 0, G_ON),
gsDPLoadTextureBlock_4b_Dolphin(con_kaiwa2_w3_tex, G_IM_FMT_I, 128, 64, 15, GX_CLAMP, GX_CLAMP, 0, 0),
gsSPVertex(&con_kaiwa2_v[0], 24, 0),
gsSPNTrianglesInit_5b(
4, // tri count
0, 1, 2, // tri0
2, 3, 0, // tri1
4, 5, 6 // tri2
),
gsSPNTriangles_5b(
6, 7, 4, // tri0
0, 0, 0, // tri1
0, 0, 0, // tri2
0, 0, 0 // tri3
),
gsDPLoadTextureBlock_4b_Dolphin(con_kaiwa2_w2_tex, G_IM_FMT_I, 128, 64, 15, GX_CLAMP, GX_CLAMP, 0, 0),
gsSPNTrianglesInit_5b(
4, // tri count
8, 9, 10, // tri0
10, 11, 8, // tri1
12, 13, 14 // tri2
),
gsSPNTriangles_5b(
14, 15, 12, // tri0
0, 0, 0, // tri1
0, 0, 0, // tri2
0, 0, 0 // tri3
),
gsDPLoadTextureBlock_4b_Dolphin(con_kaiwa2_w1_tex, G_IM_FMT_I, 64, 64, 15, GX_CLAMP, GX_CLAMP, 0, 0),
gsSPNTrianglesInit_5b(
4, // tri count
16, 17, 18, // tri0
18, 19, 16, // tri1
20, 21, 22 // tri2
),
gsSPNTriangles_5b(
22, 23, 20, // tri0
0, 0, 0, // tri1
0, 0, 0, // tri2
0, 0, 0 // tri3
),
gsSPEndDisplayList(),
};
static u8 con_namefuti_TXT[] ATTRIBUTE_ALIGN(32) = {
#include "assets/msg/con_namefuti_TXT.inc"
};
static Vtx con_kaiwaname_v[] = {
#include "assets/msg/con_kaiwaname_v.inc"
};
static Gfx con_kaiwaname_modelT[] = {
gsSPTexture(0, 0, 0, 0, G_ON),
gsDPLoadTextureBlock_4b_Dolphin(con_namefuti_TXT, G_IM_FMT_I, 64, 32, 15, GX_MIRROR, GX_MIRROR, 0, 0),
gsSPVertex(&con_kaiwaname_v[0], 4, 0),
gsSPNTrianglesInit_5b(
2, // tri count
0, 1, 2, // tri0
2, 3, 0, // tri1
0, 0, 0 // tri2
),
gsSPEndDisplayList(),
};
static Gfx mMsg_init_disp[] = {
gsDPPipeSync(),
gsSPClearGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH),
gsDPSetTextureLOD(G_TL_TILE),
gsDPSetTextureConvert(G_TC_FILT),
gsDPSetTextureFilter(G_TF_BILERP),
gsDPSetCycleType(G_CYC_1CYCLE),
gsDPSetTexturePersp(G_TP_PERSP),
gsDPSetAlphaDither(G_AD_DISABLE),
gsDPSetColorDither(G_CD_DISABLE),
gsDPSetCombineKey(G_CK_NONE),
gsDPSetCombineLERP(0, 0, 0, PRIMITIVE, 0, 0, 0, TEXEL0, 0, 0, 0, PRIMITIVE, 0, 0, 0, TEXEL0),
gsDPSetRenderMode(G_RM_XLU_SURF, G_RM_XLU_SURF2),
gsSPEndDisplayList(),
};
+53
View File
@@ -0,0 +1,53 @@
static int mMsg_Main_Disappear_SetScale(mMsg_Window_c* msg_p, GAME* game) {
const f32 max = 18.0f;
if (msg_p->timer < max) {
f32 scale;
msg_p->timer += 1.0f;
scale = 1.0f - get_percent_forAccelBrake(msg_p->timer, 0.0f, max, 0.0f, 0.0f);
msg_p->window_scale = scale;
msg_p->text_scale = scale;
return FALSE;
}
else {
msg_p->window_scale = 0.0f;
msg_p->text_scale = 0.0f;
msg_p->timer = 0.0f;
return TRUE;
}
}
static void mMsg_request_main_index_fromDisappear(mMsg_Window_c* msg_p, int scale_done_flag) {
if (scale_done_flag) {
mMsg_Change_request_main_index(msg_p, mMsg_INDEX_HIDE, 5);
}
}
static void mMsg_Main_Disappear(mMsg_Window_c* msg_p, GAME* game) {
int scaling_done_flag = mMsg_Main_Disappear_SetScale(msg_p, game);
mMsg_request_main_index_fromDisappear(msg_p, scaling_done_flag);
mMsg_MainSetup_Window(msg_p, game);
}
static void mMsg_MainSetup_Disappear(mMsg_Window_c* msg_p, GAME* game) {
mMsg_sound_spec_change_scene(msg_p);
msg_p->main_index = mMsg_INDEX_DISAPPEAR;
msg_p->draw_flag = TRUE;
msg_p->window_scale = 1.0f;
msg_p->text_scale = 1.0f;
msg_p->timer = 0.0f;
msg_p->show_continue_button = FALSE;
if (mDemo_Get_use_zoom_sound()) {
if (mDemo_Get_camera() == FALSE) {
mMsg_sound_ZOOMDOWN_SHORT(msg_p);
}
else {
mMsg_sound_ZOOMDOWN_LONG(msg_p);
}
}
msg_p->requested_main_index = -1;
msg_p->requested_priority = 4;
}
+30
View File
@@ -0,0 +1,30 @@
static void mMsg_request_main_index_fromDisappear_wait(mMsg_Window_c* msg_p, int scaling_done_flag) {
if (scaling_done_flag) {
mMsg_MainDisappearWait_Data_c* main_data = &msg_p->main_data.main_disappear_wait;
int saved_main_index = main_data->saved_main_index;
mMsg_request_main_wait(msg_p, saved_main_index, 5);
}
}
static void mMsg_Main_Disappear_wait(mMsg_Window_c* msg_p, GAME* game) {
int scaling_done = mMsg_Main_Disappear_SetScale(msg_p, game);
mMsg_request_main_index_fromDisappear_wait(msg_p, scaling_done);
mMsg_MainSetup_Window(msg_p, game);
}
static void mMsg_MainSetup_Disappear_wait(mMsg_Window_c* msg_p, GAME* game) {
mMsg_Request_MainDisappearWait_Data_c* request_data = &msg_p->request_data.request_main_disappear_wait;
mMsg_MainDisappearWait_Data_c* main_data = &msg_p->main_data.main_disappear_wait;
main_data->saved_main_index = request_data->last_main_index;
msg_p->main_index = mMsg_INDEX_DISAPPEAR_WAIT;
msg_p->draw_flag = TRUE;
msg_p->window_scale = 1.0f;
msg_p->text_scale = 1.0f;
msg_p->timer = 0.0f;
mMsg_sound_ZOOMDOWN_SHORT(msg_p);
msg_p->requested_main_index = -1;
msg_p->requested_priority = 4;
}
+118
View File
@@ -0,0 +1,118 @@
static void mMsg_draw_font(mMsg_Window_c* msg_p, GAME* game) {
mFontSentence sentence;
u8* last_p = &msg_p->msg_data->text_buf.data[msg_p->end_text_cursor_idx];
u8* start_p = &msg_p->msg_data->text_buf.data[msg_p->start_text_cursor_idx];
int line_num;
u8* cur_p;
u8 code;
u8 cont_type;
int len;
int line_len;
int total_len;
xy_t scale;
xy_t pos;
Gfx* gfx;
int line_end_flag;
int sentence_finished_flag;
u32 sentence_flags;
int sentence_voice_idx = msg_p->voice_sfx_idx - msg_p->start_text_cursor_idx;
int voice = FALSE;
if (fabsf(msg_p->text_scale) < 0.001f) {
return;
}
OPEN_DISP(game->graph);
gfx = NOW_FONT_DISP;
scale.x = msg_p->text_scale;
scale.y = msg_p->text_scale;
pos.x = msg_p->center_x - (96.0f * scale.x);
pos.y = msg_p->center_y - (32.0f * scale.y);
if ((msg_p->status_flags & mMsg_STATUS_FLAG_VOICE_ENTRY)) {
if ((msg_p->status_flags & mMsg_STATUS_FLAG_18)) {
voice = TRUE;
}
else if (!F32_IS_ZERO(msg_p->cursor_timer) || msg_p->force_voice_enable_flag == TRUE) {
voice = TRUE;
}
}
line_num = 0;
sentence_finished_flag = FALSE;
total_len = 0;
while (line_num < msg_p->text_lines && sentence_finished_flag == FALSE) {
for (
line_len = 0, cur_p = start_p, line_end_flag = FALSE;
cur_p < last_p && line_end_flag == FALSE;
len = mFont_CodeSize_get(cur_p), cur_p += len, line_len += len
) {
code = cur_p[0];
if (code == CHAR_NEW_LINE) {
line_end_flag = TRUE;
}
else if (code == CHAR_CONTROL_CODE) {
cont_type = cur_p[1];
if (
cont_type == mFont_CONT_CODE_LAST ||
cont_type == mFont_CONT_CODE_CONTINUE ||
cont_type == mFont_CONT_CODE_MSG_TIME_END
) {
line_end_flag = TRUE;
sentence_finished_flag = TRUE;
}
}
}
if (cur_p >= last_p) {
sentence_finished_flag = TRUE;
}
if (line_num == 0) {
sentence_flags = mFont_SENTENCE_SKIP_DRAW_NEW_LINE | mFont_SENTENCE_FLAG_CUT;
}
else {
sentence_flags = mFont_SENTENCE_SKIP_DRAW_NEW_LINE | mFont_SENTENCE_FLAG_NO_COMBINE | mFont_SENTENCE_FLAG_3 | mFont_SENTENCE_FLAG_CUT;
}
if (
voice &&
sentence_voice_idx >= total_len &&
sentence_voice_idx < (total_len + line_len)
) {
sentence_flags |= mFont_SENTENCE_FLAG_VOICE_SE;
msg_p->status_flags &= ~(mMsg_STATUS_FLAG_18 | mMsg_STATUS_FLAG_VOICE_ENTRY);
}
mFontSentence_set(
&sentence,
start_p,
line_len,
sentence_flags,
&pos,
mFont_LineType_Top,
&scale,
&msg_p->font_color[line_num],
sentence_voice_idx - total_len,
msg_p->voice_idx,
msg_p->voice2_idx,
msg_p->voice3_idx,
msg_p->animal_voice_idx
);
mFontSentence_gppDraw(&sentence, game, &gfx);
pos.y += 16.0f * scale.y;
start_p = cur_p;
line_num++;
total_len += line_len;
}
SET_FONT_DISP(gfx);
CLOSE_DISP(game->graph);
}
+107
View File
@@ -0,0 +1,107 @@
static void mMsg_SetMatrix(mMsg_Window_c* msg_p, GAME* game, int mode) {
GRAPH* graph = game->graph;
f32 scale = msg_p->window_scale;
f32 center_x = ( msg_p->center_x - (SCREEN_WIDTH_F * 0.5f)) * 16.0f;
f32 center_y = (-msg_p->center_y + (SCREEN_HEIGHT_F * 0.5f)) * 16.0f;
Matrix_push();
Matrix_translate(center_x, center_y, 0.0f, 1);
Matrix_scale(scale, scale, scale, 1);
OPEN_DISP(graph);
if (mode == mFont_MODE_FONT) {
gSPMatrix(NOW_FONT_DISP++, _Matrix_to_Mtx_new(graph), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH);
}
else {
gSPMatrix(NOW_POLY_OPA_DISP++, _Matrix_to_Mtx_new(graph), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH);
}
CLOSE_DISP(graph);
}
static void mMsg_UnSetMatrix() {
Matrix_pull();
}
static void mMsg_DrawNameWindow(mMsg_Window_c* msg_p, GAME* game, int mode) {
GRAPH* graph = game->graph;
OPEN_DISP(graph);
if (mode == mFont_MODE_FONT) {
gDPSetPrimColor(NOW_FONT_DISP++, 0, 255, msg_p->name_background_color.r, msg_p->name_background_color.g, msg_p->name_background_color.b, 255);
gSPDisplayList(NOW_FONT_DISP++, con_kaiwaname_modelT);
}
else {
gDPSetPrimColor(NOW_POLY_OPA_DISP++, 0, 255, msg_p->name_background_color.r, msg_p->name_background_color.g, msg_p->name_background_color.b, 255);
gSPDisplayList(NOW_POLY_OPA_DISP++, con_kaiwaname_modelT);
}
CLOSE_DISP(graph);
}
static void mMsg_DrawWindowClientName(mMsg_Window_c* msg_p, GAME* game, int mode) {
u8 name[ANIMAL_NAME_LEN];
mNpc_GetNpcWorldName(name, msg_p->client_actor_p);
mFont_SetLineStrings_AndSpace(
game,
name, msg_p->client_name_len,
msg_p->nameplate_x, msg_p->nameplate_y,
msg_p->name_text_color.r, msg_p->name_text_color.g, msg_p->name_text_color.b, msg_p->name_text_color.a,
FALSE,
TRUE,
TRUE,
1.0f, 1.0f,
mode
);
}
static void mMsg_DrawWindowTurnButton(mMsg_Window_c* msg_p, GAME* game, int mode) {
if (msg_p->show_continue_button != FALSE && msg_p->lock_continue == FALSE) {
mFont_SetMarkChar(
game,
mFont_MARKTYPE_NEXT,
257.0f, 136.0f,
msg_p->continue_button_color.r, msg_p->continue_button_color.g, msg_p->continue_button_color.b, msg_p->continue_button_color.a,
FALSE,
1.0f, 1.0f,
mode
);
}
}
static void mMsg_DrawWindowBody(mMsg_Window_c* msg_p, GAME* game, int mode) {
GRAPH* graph = game->graph;
rgba_t* window_background_color = &msg_p->window_background_color;
OPEN_DISP(graph);
if (mode == mFont_MODE_FONT) {
gSPDisplayList(NOW_FONT_DISP++, mMsg_init_disp);
gDPSetPrimColor(NOW_FONT_DISP++, 0, 255, window_background_color->r, window_background_color->g, window_background_color->b, window_background_color->a);
gSPDisplayList(NOW_FONT_DISP++, con_kaiwa2_modelT);
if (msg_p->show_actor_name) {
mMsg_DrawNameWindow(msg_p, game, mode);
mMsg_DrawWindowClientName(msg_p, game, mode);
}
mMsg_DrawWindowTurnButton(msg_p, game, mode);
}
else {
gSPDisplayList(NOW_POLY_OPA_DISP++, mMsg_init_disp);
gDPSetPrimColor(NOW_POLY_OPA_DISP++, 0, 255, window_background_color->r, window_background_color->g, window_background_color->b, window_background_color->a);
gSPDisplayList(NOW_POLY_OPA_DISP++, con_kaiwa2_modelT);
if (msg_p->show_actor_name) {
mMsg_DrawNameWindow(msg_p, game, mode);
mMsg_DrawWindowClientName(msg_p, game, mode);
}
mMsg_DrawWindowTurnButton(msg_p, game, mode);
}
CLOSE_DISP(graph);
}
+8
View File
@@ -0,0 +1,8 @@
static void mMsg_Main_Hide(mMsg_Window_c* msg_p, GAME* game) {
mMsg_MainSetup_Window(msg_p, game);
}
static void mMsg_MainSetup_Hide(mMsg_Window_c* msg_p, GAME* game) {
mMsg_init(game);
emu64_refresh();
}
+983
View File
@@ -0,0 +1,983 @@
static int mMsg_Set_SizeCode(mMsg_Window_c* msg_p, int idx) {
return mFont_CodeSize_idx_get(msg_p->msg_data->text_buf.data, idx);
}
static int mMsg_Count_SameCode(u8* data, int start, int length, u8 code) {
int res = 0;
int i = start;
u8* now_p;
u8 now_code;
while (i < length) {
now_p = &data[i];
now_code = *now_p;
if (now_code == CHAR_CONTROL_CODE) {
i += mFont_CodeSize_get(now_p);
}
else if (now_code == code) {
res++;
i++;
}
else {
break;
}
}
return res;
}
static int mMsg_Check_LastCode_forData(u8* data, int idx) {
u8 code = data[idx];
if (code == CHAR_CONTROL_CODE) {
code = data[idx + 1];
if (code == mFont_CONT_CODE_LAST) {
return TRUE;
}
}
return FALSE;
}
static int mMsg_Check_LastCode(mMsg_Window_c* msg_p, int idx) {
return mMsg_Check_LastCode_forData(msg_p->msg_data->text_buf.data, idx);
}
static int mMsg_Check_ContinueCode_forData(u8* data, int idx) {
u8 code = data[idx];
if (code == CHAR_CONTROL_CODE) {
code = data[idx + 1];
if (code == mFont_CONT_CODE_CONTINUE) {
return TRUE;
}
}
return FALSE;
}
static int mMsg_Check_ContinueCode(mMsg_Window_c* msg_p, int idx) {
return mMsg_Check_ContinueCode_forData(msg_p->msg_data->text_buf.data, idx);
}
static int mMsg_Check_NextIndex_ContinueCode(mMsg_Window_c* msg_p) {
if (mMsg_Check_ContinueCode(msg_p, msg_p->end_text_cursor_idx)) {
return TRUE;
}
return FALSE;
}
static int mMsg_Check_NextIndex_LastCode(mMsg_Window_c* msg_p) {
if (mMsg_Check_LastCode(msg_p, msg_p->end_text_cursor_idx)) {
return TRUE;
}
return FALSE;
}
static int mMsg_Check_NextIndex_SetSelectWindowCode(mMsg_Window_c* msg_p) {
u8* data = msg_p->msg_data->text_buf.data;
int idx = msg_p->end_text_cursor_idx;
u8 code = data[idx];
if (code == CHAR_CONTROL_CODE) {
code = data[idx + 1];
if (code == mFont_CONT_CODE_SET_SELECT_WINDOW) {
return TRUE;
}
}
return FALSE;
}
static f32 mMsg_Get_CursolSetTimeCode_forData(u8* data, int idx) {
u8 code = data[idx];
if (code == CHAR_CONTROL_CODE) {
code = data[idx + 1];
if (code == mFont_CONT_CODE_CURSOR_SET_TIME) {
code = data[idx + 2];
return (f32)(int)code * 2.0f; /* Multiply by two due to AC running at 60fps over 30fps */
}
}
return 0.0f;
}
static f32 mMsg_Get_CursolSetTimeCode(mMsg_Window_c* msg_p, int idx) {
return mMsg_Get_CursolSetTimeCode_forData(msg_p->msg_data->text_buf.data, idx);
}
static int mMsg_Get_ColorCode_forData(u8* data, int idx, u8* r, u8* g, u8* b) {
u8 code = data[idx];
if (code == CHAR_CONTROL_CODE) {
code = data[idx + 1];
if (code == mFont_CONT_CODE_COLOR) {
*r = data[idx + 2];
*g = data[idx + 3];
*b = data[idx + 4];
return TRUE;
}
}
return FALSE;
}
static int mMsg_Get_ColorCode(mMsg_Window_c* msg_p, int idx, u8* r, u8* g, u8* b) {
return mMsg_Get_ColorCode_forData(msg_p->msg_data->text_buf.data, idx, r, g, b);
}
static int mMsg_Get_OrderCode_forData(u8* data, int idx, int* order_idx, u16* order_val) {
u8 code = data[idx];
if (code == CHAR_CONTROL_CODE) {
code = data[idx + 1];
if (
code == mFont_CONT_CODE_SET_DEMO_ORDER_PLAYER ||
code == mFont_CONT_CODE_SET_DEMO_ORDER_NPC0 ||
code == mFont_CONT_CODE_SET_DEMO_ORDER_NPC1 ||
code == mFont_CONT_CODE_SET_DEMO_ORDER_NPC2 ||
code == mFont_CONT_CODE_SET_DEMO_ORDER_QUEST
) {
u16 val;
*order_idx = data[idx + 2];
val = (u16)(data[idx + 3]) << 8;
*order_val = val | ((data[idx + 4]) & 0xFF);
return TRUE;
}
}
return FALSE;
}
static int mMsg_Get_OrderCode(mMsg_Window_c* msg_p, int idx, int* order_idx, u16* order_val) {
return mMsg_Get_OrderCode_forData(msg_p->msg_data->text_buf.data, idx, order_idx, order_val);
}
static int mMsg_Get_SoundCutCode_forData(u8* data, int idx) {
if (data[idx] == CHAR_CONTROL_CODE && data[idx + 1] == mFont_CONT_CODE_SOUND_CUT) {
return data[idx + 2];
}
return FALSE;
}
static int mMsg_Get_SoundCutCode(mMsg_Window_c* msg_p, int idx) {
return mMsg_Get_SoundCutCode_forData(msg_p->msg_data->text_buf.data, idx);
}
static void mMsg_Get_bgm_make_forData(u8* data, int idx, int* bgm_type, int* stop_type) {
u8* code_p = &data[idx];
if (
code_p[0] == CHAR_CONTROL_CODE &&
code_p[1] == mFont_CONT_CODE_BGM_MAKE &&
code_p[2] < mFont_BGM_NUM &&
code_p[3] < mFont_BGM_STOP_TYPE_NUM
) {
*bgm_type = code_p[2];
*stop_type = code_p[3];
}
else {
*bgm_type = mFont_BGM_NUM;
*stop_type = mFont_BGM_STOP_TYPE_NUM;
}
}
static void mMsg_Get_bgm_make(mMsg_Window_c* msg_p, int idx, int* bgm_type, int* stop_type) {
mMsg_Get_bgm_make_forData(msg_p->msg_data->text_buf.data, idx, bgm_type, stop_type);
}
static void mMsg_Get_bgm_delete_forData(u8* data, int idx, int* bgm_type, int* stop_type) {
u8* code_p = &data[idx];
if (
code_p[0] == CHAR_CONTROL_CODE &&
code_p[1] == mFont_CONT_CODE_BGM_DELETE &&
code_p[2] < mFont_BGM_NUM &&
code_p[3] < mFont_BGM_STOP_TYPE_NUM
) {
*bgm_type = code_p[2];
*stop_type = code_p[3];
}
else {
*bgm_type = mFont_BGM_NUM;
*stop_type = mFont_BGM_STOP_TYPE_NUM;
}
}
static void mMsg_Get_bgm_delete(mMsg_Window_c* msg_p, int idx, int* bgm_type, int* stop_type) {
mMsg_Get_bgm_delete_forData(msg_p->msg_data->text_buf.data, idx, bgm_type, stop_type);
}
static int mMsg_Get_MsgTimeEnd_time_forData(u8* data, int idx) {
u8* code_p = &data[idx];
if (code_p[0] == CHAR_CONTROL_CODE && code_p[1] == mFont_CONT_CODE_MSG_TIME_END) {
return code_p[2];
}
return 0;
}
static int mMsg_Get_MsgTimeEnd_time(mMsg_Window_c* msg_p, int idx) {
return mMsg_Get_MsgTimeEnd_time_forData(msg_p->msg_data->text_buf.data, idx);
}
static int mMsg_Check_MsgTimeEndCode_forData(u8* data, int idx) {
u8* code_p = &data[idx];
return (code_p[0] == CHAR_CONTROL_CODE && code_p[1] == mFont_CONT_CODE_MSG_TIME_END);
}
static int mMsg_Check_MsgTimeEndCode(mMsg_Window_c* msg_p, int idx) {
return mMsg_Check_MsgTimeEndCode_forData(msg_p->msg_data->text_buf.data, idx);
}
static int mMsg_Check_NextIndex_MsgTimeEndCode(mMsg_Window_c* msg_p) {
return mMsg_Check_MsgTimeEndCode(msg_p, msg_p->end_text_cursor_idx);
}
static void mMsg_Get_sound_trg_sys_forData(u8* data, int idx, int* se_no) {
u8* code_p = &data[idx];
if (
code_p[0] == CHAR_CONTROL_CODE &&
code_p[1] == mFont_CONT_CODE_SOUND_TRG_SYS &&
code_p[2] < mFont_SE_NUM
) {
*se_no = code_p[2];
}
else {
*se_no = mFont_SE_NUM;
}
}
static void mMsg_Get_sound_trg_sys(mMsg_Window_c* msg_p, int idx, int* se_no) {
mMsg_Get_sound_trg_sys_forData(msg_p->msg_data->text_buf.data, idx, se_no);
}
static void mMsg_Set_LineFontColor(mMsg_Window_c* msg_p, int line_no, u8 r, u8 g, u8 b, u8 a) {
if (line_no >= 0 && line_no < mMsg_MAX_LINE) {
rgba_t* color = &msg_p->font_color[line_no];
color->r = r;
color->g = g;
color->b = b;
color->a = a;
}
}
static void mMsg_init_FontColor(mMsg_Window_c* msg_p) {
int i;
for (i = 0; i < mMsg_MAX_LINE; i++) {
mMsg_Set_LineFontColor(msg_p, i, 50, 60, 50, 255);
}
}
static void mMsg_init_NowDisplayLIne(mMsg_Window_c* msg_p) {
msg_p->now_display_line = 0;
}
static void mMsg_Clear_CursolIndex(mMsg_Window_c* msg_p) {
msg_p->start_text_cursor_idx = msg_p->end_text_cursor_idx;
mMsg_init_FontColor(msg_p);
mMsg_init_NowDisplayLIne(msg_p);
}
static void mMsg_SetTimer(mMsg_Window_c* msg_p, f32 timer) {
msg_p->cursor_timer = timer;
}
extern void mMsg_Get_BodyParam(u32 table_addr, u32 data_addr, int index, u32* addr, u32* size) {
static u32 tmp_buff[16] ATTRIBUTE_ALIGN(32);
int first_entry = index == 0;
u32 aligned_ofs = first_entry ? 0 : ALIGN_PREV((index - 1) * sizeof(u32), 32);
int ofs = first_entry ? 0 : (index - 1) & 7;
_JW_GetResourceAram(table_addr + aligned_ofs, (u8*)tmp_buff, sizeof(tmp_buff));
if (first_entry) {
*addr = data_addr;
*size = tmp_buff[ofs];
}
else {
*addr = data_addr + tmp_buff[ofs];
*size = tmp_buff[ofs + 1] - tmp_buff[ofs];
}
}
static void mMsg_Get_MsgDataAddressAndSize(int idx, u32* addr, u32* size) {
mMsg_Get_BodyParam(Msg_table_rom_start, Msg_rom_start, idx, addr, size);
}
static int mMsg_Count_MsgData(u8* data) {
int i = 0;
while (i < mMsg_MSG_BUF_MAX) {
if (
mMsg_Check_LastCode_forData(data, i) ||
mMsg_Check_ContinueCode_forData(data, i) ||
mMsg_Check_MsgTimeEndCode_forData(data, i)
) {
i += mFont_CodeSize_idx_get(data, i);
break;
}
i += mFont_CodeSize_idx_get(data, i);
}
return i;
}
static int mMsg_LoadMsgData(mMsg_Data_c* msg_data, int index, int cut) {
if (msg_data != NULL) {
u32 addr;
u32 size;
mFRm_set_msg_idx(index);
mMsg_Get_MsgDataAddressAndSize(index, &addr, &size);
if (addr != 0 && size != 0) {
u32 aligned_addr = ALIGN_PREV(addr, 32);
int ofs = addr - aligned_addr;
u8* dst_p;
u8* src_p;
int len;
int i;
/* DMA copy from ARAM */
_JW_GetResourceAram(aligned_addr, msg_data->text_buf.data, ALIGN_NEXT(ofs + size, 32));
/* Move text to beginning of buffer since we copied aligned to 32 bytes */
len = size;
dst_p = msg_data->text_buf.data;
src_p = msg_data->text_buf.data + ofs;
for (i = 0; i < len; i++) {
*dst_p++ = *src_p++;
}
msg_data->msg_no = index;
msg_data->data_loaded = TRUE;
msg_data->msg_len = mMsg_Count_MsgData(msg_data->text_buf.data);
msg_data->cut = cut;
return TRUE;
}
}
msg_data->data_loaded = FALSE;
return FALSE;
}
extern int mMsg_ChangeMsgData(mMsg_Window_c* msg_p, int index) {
if (index >= 0 && index < MSG_MAX && mMsg_LoadMsgData(msg_p->msg_data, index, FALSE)) {
msg_p->end_text_cursor_idx = 0;
mMsg_Clear_CursolIndex(msg_p);
mMsg_SetTimer(msg_p, 20.0f);
return TRUE;
}
return FALSE;
}
static void mMsg_Unset_NowUtter(mMsg_Window_c* msg_p) {
msg_p->now_utter = FALSE;
}
static void mMsg_Set_NowUtter(mMsg_Window_c* msg_p) {
msg_p->now_utter = TRUE;
}
extern int mMsg_Check_NowUtter() {
return mMsg_Get_base_window_p()->now_utter;
}
static void mMsg_init(GAME* game) {
mMsg_data.data_loaded = FALSE;
mMsg_window.data_loaded = FALSE;
mMsg_window.msg_no = 0;
mMsg_window._008 = 0;
mMsg_window.msg_data = &mMsg_data;
mMsg_window.center_x = 160.0;
mMsg_window.center_y = 185.4;
mMsg_window.width = 245.0;
mMsg_window.height = 96.0;
mMsg_window.client_actor_p = NULL;
mMsg_window.client_name_len = 0;
mMsg_window.nameplate_x = 61.0;
mMsg_window.nameplate_y = 64.0;
mMsg_window.show_continue_button = FALSE;
mMsg_window.name_text_color.r = 0x32;
mMsg_window.name_text_color.g = 0x5a;
mMsg_window.name_text_color.b = 0;
mMsg_window.name_text_color.a = 0xff;
mMsg_window.name_background_color.r = 0xa0;
mMsg_window.name_background_color.g = 0xd7;
mMsg_window.name_background_color.b = 0x1e;
mMsg_window.name_background_color.a = 0xff;
mMsg_window.window_background_color.r = 0xeb;
mMsg_window.window_background_color.g = 0xff;
mMsg_window.window_background_color.b = 0xeb;
mMsg_window.window_background_color.a = 0xff;
mMsg_init_FontColor(&mMsg_window);
mMsg_init_NowDisplayLIne(&mMsg_window);
mMsg_window.continue_button_color.r = 0;
mMsg_window.continue_button_color.g = 0;
mMsg_window.continue_button_color.b = 0xff;
mMsg_window.continue_button_color.a = 0;
mMsg_window.font_scale_x = 1.0;
mMsg_window.font_scale_y = 1.0;
mMsg_window._2D8 = 196;
mMsg_window._2DC = 66;
mMsg_window.text_lines = mMsg_MAX_LINE;
mMsg_window.now_display_line = 0;
mMsg_window.timer = 0.0;
mMsg_SetTimer(&mMsg_window, 0.0);
mMsg_window.continue_button_timer = 0.0;
mMsg_window.start_text_cursor_idx = 0;
mMsg_window.end_text_cursor_idx = 0;
mMsg_window.window_scale = 0.0;
mMsg_window.text_scale = 1.0;
mMsg_window.requested_main_index = -1;
mMsg_window.requested_priority = 0;
mMsg_window.main_index = mMsg_INDEX_HIDE;
mMsg_window.draw_flag = 0;
mMsg_window.cancel_flag = 0;
mMsg_window.cancelable_flag = 0;
mMsg_window.continue_msg_no = 0xFFFF;
mMsg_Unset_CancelNormalContinue(&mMsg_window);
mMsg_Unset_ForceNext(&mMsg_window);
mMsg_Unset_LockContinue(&mMsg_window);
mMsg_sound_MessageSpeedForce(0.0f);
mMsg_sound_MessageStatus(0);
mMsg_window.status_flags &= ~(
mMsg_STATUS_FLAG_SOUND_CUT |
mMsg_STATUS_FLAG_IDLING_REQ |
mMsg_STATUS_FLAG_IDLING_NOW |
mMsg_STATUS_FLAG_NOT_PAUSE_FRAME |
mMsg_STATUS_FLAG_NO_ZOOMDOWN |
mMsg_STATUS_FLAG_VOICE_CLICK |
mMsg_STATUS_FLAG_VOICE_SILENT |
mMsg_STATUS_FLAG_CURSOL_JUST
); // ~7AC1
mMsg_window.free_str_color_idx[0] = 0;
mMsg_window.free_str_color_idx[1] = 0;
mMsg_window.free_str_color_idx[2] = 0;
}
extern int mMsg_Get_Length_String(u8* str, int str_len) {
int i;
for (i = str_len - 1; i >= 0; i--) {
if (str[i] != CHAR_SPACE) {
break;
}
}
return i + 1;
}
extern int mMsg_Check_MainNormalContinue(mMsg_Window_c* msg_p) {
if (msg_p->main_index == mMsg_INDEX_NORMAL) {
if (mMsg_Check_NextIndex_ContinueCode(msg_p)) {
return TRUE;
}
}
return FALSE;
}
extern int mMsg_Check_MainNormal(mMsg_Window_c* msg_p) {
if (msg_p->main_index == mMsg_INDEX_NORMAL) {
return TRUE;
}
return FALSE;
}
extern int mMsg_Check_MainHide(mMsg_Window_c* msg_p) {
if (msg_p->main_index == mMsg_INDEX_HIDE) {
return TRUE;
}
return FALSE;
}
extern int mMsg_Check_MainDisappear(mMsg_Window_c* msg_p) {
if (msg_p->main_index == mMsg_INDEX_DISAPPEAR) {
return TRUE;
}
return FALSE;
}
extern void mMsg_Set_CancelNormalContinue(mMsg_Window_c* msg_p) {
msg_p->continue_cancel_flag = TRUE;
}
extern void mMsg_Unset_CancelNormalContinue(mMsg_Window_c* msg_p) {
msg_p->continue_cancel_flag = FALSE;
}
extern void mMsg_Set_ForceNext(mMsg_Window_c* msg_p) {
msg_p->force_next = TRUE;
}
extern void mMsg_Unset_ForceNext(mMsg_Window_c* msg_p) {
msg_p->force_next = FALSE;
}
/* @unused @fabricated */
// extern int mMsg_Get_LockContinue(mMsg_Window_c* msg_p) {
// return msg_p->lock_continue;
// }
extern void mMsg_Set_LockContinue(mMsg_Window_c* msg_p) {
msg_p->lock_continue = TRUE;
}
extern void mMsg_Unset_LockContinue(mMsg_Window_c* msg_p) {
msg_p->lock_continue = FALSE;
}
extern void mMsg_Set_idling_req(mMsg_Window_c* msg_p) {
msg_p->status_flags |= mMsg_STATUS_FLAG_IDLING_REQ;
}
extern int mMsg_Check_idling_now(mMsg_Window_c* msg_p) {
return (msg_p->status_flags & mMsg_STATUS_FLAG_IDLING_NOW) != 0;
}
extern int mMsg_MoveDataCut(u8* data, int dst_idx, int src_idx, int len, int space_flag) {
int new_len = len;
if (dst_idx < src_idx) {
while (src_idx < len) {
data[dst_idx] = data[src_idx];
dst_idx++;
src_idx++;
}
new_len -= src_idx - dst_idx;
if (space_flag) {
while (dst_idx < len) {
data[dst_idx] = CHAR_SPACE;
dst_idx++;
}
}
}
else if (dst_idx > src_idx) {
int move_size = len - src_idx;
new_len += dst_idx - src_idx;
if (new_len <= mMsg_MSG_BUF_MAX) {
int i;
u8* dst_p = data + new_len - 1;
u8* src_p = data + len - 1;
for (i = 0; i < move_size; i++) {
*dst_p-- = *src_p--;
}
}
}
return new_len;
}
static void mMsg_CopyString(u8* dst, u8* src, int len) {
int i;
for (i = 0; i < len; i++) {
*dst++ = *src++;
}
}
static int mMsg_Set_PlayerNameColor(u8* data, int* start_idx, int len) {
static u8 add_string[] = {
CHAR_CONTROL_CODE,
mFont_CONT_CODE_SET_COLOR_CHAR,
75,
95,
155,
0
};
u8* name = Common_Get(now_private)->player_ID.player_name;
int name_len = mMsg_Get_Length_String(name, PLAYER_NAME_LEN);
int hypen_count;
int new_len;
int initial_start_idx = *start_idx;
int command_len = mFont_CodeSize_idx_get(data, *start_idx);
if (name_len > 0) {
hypen_count = mMsg_Count_SameCode(data, (*start_idx) + command_len, len, CHAR_HYPHEN);
add_string[5] = name_len + hypen_count;
new_len = mMsg_MoveDataCut(data, initial_start_idx + sizeof(add_string), initial_start_idx, len, FALSE);
mMsg_CopyString(data + initial_start_idx, add_string, sizeof(add_string));
*start_idx += sizeof(add_string);
}
else {
new_len = len;
}
return new_len;
}
extern int mMsg_CopyPlayerName(u8* data, int start_idx, int len, u32 capitalize) {
int command_len = mFont_CodeSize_idx_get(data, start_idx);
u8* name = Common_Get(now_private)->player_ID.player_name;
int name_len = mMsg_Get_Length_String(name, PLAYER_NAME_LEN);
int new_len = mMsg_MoveDataCut(data, start_idx + name_len, start_idx + command_len, len, FALSE);
mMsg_CopyString(&data[start_idx], name, name_len);
if (capitalize) {
data[start_idx] = mFont_small_to_capital(data[start_idx]);
}
return new_len;
}
extern int mMsg_CopyTalkName(ACTOR* actor_p, u8* data, int start_idx, int len, u32 capitalize) {
int command_len = mFont_CodeSize_idx_get(data, start_idx);
u8 name[ANIMAL_NAME_LEN];
int name_len;
int new_len;
if (actor_p != NULL) {
mNpc_GetNpcWorldName(name, actor_p);
name_len = mMsg_Get_Length_String(name, sizeof(name));
}
else {
name_len = 0;
}
new_len = mMsg_MoveDataCut(data, start_idx + name_len, start_idx + command_len, len, FALSE);
mMsg_CopyString(&data[start_idx], name, name_len);
if (capitalize) {
data[start_idx] = mFont_small_to_capital(data[start_idx]);
}
return new_len;
}
extern int mMsg_CopyTail(ACTOR* actor_p, u8* data, int start_idx, int len, u32 capitalize) {
int command_len = mFont_CodeSize_idx_get(data, start_idx);
u8* tail_p = actor_p != NULL ? mNpc_GetWordEnding(actor_p) : NULL;
int tail_len = actor_p != NULL ? mMsg_Get_Length_String(tail_p, ANIMAL_CATCHPHRASE_LEN) : 0;
int new_len;
new_len = mMsg_MoveDataCut(data, start_idx + tail_len, start_idx + command_len, len, FALSE);
mMsg_CopyString(&data[start_idx], tail_p, tail_len);
if (capitalize) {
data[start_idx] = mFont_small_to_capital(data[start_idx]);
}
return new_len;
}
extern int mMsg_CopyYear(u8* data, int start_idx, int len) {
int command_len = mFont_CodeSize_idx_get(data, start_idx);
u16 year = Common_Get(time.rtc_time.year);
u8 year_str[6];
int year_len = mString_Load_YearStringFromRom(year_str, year);
int new_len = mMsg_MoveDataCut(data, start_idx + year_len, start_idx + command_len, len, FALSE);
mMsg_CopyString(&data[start_idx], year_str, year_len);
return new_len;
}
extern int mMsg_CopyMonth(u8* data, int start_idx, int len) {
int command_len = mFont_CodeSize_idx_get(data, start_idx);
u8 month = Common_Get(time.rtc_time.month);
u8 month_str[9];
int month_len = mString_Load_MonthStringFromRom(month_str, month);
int new_len = mMsg_MoveDataCut(data, start_idx + month_len, start_idx + command_len, len, FALSE);
mMsg_CopyString(&data[start_idx], month_str, month_len);
return new_len;
}
extern int mMsg_CopyWeek(u8* data, int start_idx, int len) {
int command_len = mFont_CodeSize_idx_get(data, start_idx);
u8 week = Common_Get(time.rtc_time.weekday);
u8 week_str[9];
int week_len = mString_Load_WeekStringFromRom(week_str, week);
int new_len = mMsg_MoveDataCut(data, start_idx + week_len, start_idx + command_len, len, FALSE);
mMsg_CopyString(&data[start_idx], week_str, week_len);
return new_len;
}
extern int mMsg_CopyDay(u8* data, int start_idx, int len) {
int command_len = mFont_CodeSize_idx_get(data, start_idx);
u8 day = Common_Get(time.rtc_time.day);
u8 day_str[4];
int day_len = mString_Load_DayStringFromRom(day_str, day);
int new_len = mMsg_MoveDataCut(data, start_idx + day_len, start_idx + command_len, len, FALSE);
mMsg_CopyString(&data[start_idx], day_str, day_len);
return new_len;
}
extern int mMsg_CopyHour(u8* data, int start_idx, int len) {
int command_len = mFont_CodeSize_idx_get(data, start_idx);
u8 hour = Common_Get(time.rtc_time.hour);
u8 hour_str[2];
int hour_len = mString_Load_HourStringFromRom2(hour_str, hour);
int new_len = mMsg_MoveDataCut(data, start_idx + hour_len, start_idx + command_len, len, FALSE);
mMsg_CopyString(&data[start_idx], hour_str, hour_len);
return new_len;
}
extern int mMsg_CopyMin(u8* data, int start_idx, int len) {
int command_len = mFont_CodeSize_idx_get(data, start_idx);
u8 min = Common_Get(time.rtc_time.min);
u8 min_str[2];
int min_len = mString_Load_MinStringFromRom(min_str, min);
int new_len = mMsg_MoveDataCut(data, start_idx + min_len, start_idx + command_len, len, FALSE);
mMsg_CopyString(&data[start_idx], min_str, min_len);
return new_len;
}
extern int mMsg_CopySec(u8* data, int start_idx, int len) {
int command_len = mFont_CodeSize_idx_get(data, start_idx);
u8 sec = Common_Get(time.rtc_time.sec);
u8 sec_str[2];
int sec_len = mString_Load_SecStringFromRom(sec_str, sec);
int new_len = mMsg_MoveDataCut(data, start_idx + sec_len, start_idx + command_len, len, FALSE);
mMsg_CopyString(&data[start_idx], sec_str, sec_len);
return new_len;
}
extern int mMsg_CopyFree(mMsg_Window_c* msg_p, int str_no, u8* data, int start_idx, int len, int article, u32 capitalize) {
if (str_no < 0 || str_no >= mMsg_FREE_STR_NUM) {
str_no = mMsg_FREE_STR0;
}
{
int new_len;
int command_len = mFont_CodeSize_idx_get(data, start_idx);
u8* free_str_p = msg_p->free_str[str_no];
int free_str_len = mMsg_Get_Length_String(free_str_p, mMsg_FREE_STRING_LEN);
new_len = mMsg_MoveDataCut(data, start_idx + free_str_len, start_idx + command_len, len, FALSE);
mMsg_CopyString(&data[start_idx], free_str_p, free_str_len);
article = article != mIN_ARTICLE_NUM ? article : msg_p->free_str_article[str_no];
if (article != mIN_ARTICLE_NONE) {
u8 article_str[mIN_ITEM_NAME_LEN + 1];
int article_len;
mString_Load_StringFromRom(article_str, mIN_ITEM_NAME_LEN, mString_ARTICLE_START + article);
article_len = mMsg_Get_Length_String(article_str, mIN_ITEM_NAME_LEN);
article_str[article_len] = CHAR_SPACE;
new_len = mMsg_MoveDataCut(data, start_idx + article_len + 1, start_idx, new_len, FALSE);
mMsg_CopyString(&data[start_idx], article_str, article_len + 1);
}
if (capitalize) {
data[start_idx] = mFont_small_to_capital(data[start_idx]);
}
return new_len;
}
}
static u8 MMSG_pf_cl[6][3] = {
{ 0, 0, 0 },
{ 145, 60, 145 },
{ 50, 130, 70 },
{ 75, 95, 155 },
{ 160, 50, 75 },
{ 50, 75, 225 }
};
static int mMsg_Set_PfColor(u8* data, int* start_idx, int len, u8* free_str, int pf_color_id, int article) {
static u8 add_string[] = { CHAR_CONTROL_CODE, mFont_CONT_CODE_SET_COLOR_CHAR, 0, 0, 0, 0 };
int free_str_len = mMsg_Get_Length_String(free_str, mMsg_FREE_STRING_LEN);
int article_len;
int src_idx = *start_idx;
int new_len;
u8* color_data = MMSG_pf_cl[pf_color_id];
add_string[2] = color_data[0];
add_string[3] = color_data[1];
add_string[4] = color_data[2];
if (article == mIN_ARTICLE_NONE) {
article_len = 0;
}
else {
u8 article_str[mIN_ITEM_NAME_LEN];
mString_Load_StringFromRom(article_str, mIN_ITEM_NAME_LEN, mString_ARTICLE_START + article);
article_len = mMsg_Get_Length_String(article_str, mIN_ITEM_NAME_LEN) + 1;
}
add_string[5] = free_str_len + article_len;
new_len = mMsg_MoveDataCut(data, src_idx + sizeof(add_string), src_idx, len, FALSE);
mMsg_CopyString(data + src_idx, add_string, sizeof(add_string));
(*start_idx) += sizeof(add_string);
return new_len;
}
extern int mMsg_CopyDetermination(mMsg_Window_c* msg_p, u8* data, int start_idx, int len) {
int command_len = mFont_CodeSize_idx_get(data, start_idx);
u8* str = msg_p->choice_window.data.determination_string;
int str_len = msg_p->choice_window.data.determination_len;
int new_len = mMsg_MoveDataCut(data, start_idx + str_len, start_idx + command_len, len, FALSE);
mMsg_CopyString(&data[start_idx], str, str_len);
return new_len;
}
extern int mMsg_CopyCountryName(u8 *data, int start_idx, int len, u32 capitalize) {
int new_len;
int new_start_idx;
int command_len = mFont_CodeSize_idx_get(data, start_idx);
u8* land_name = mLd_GetLandName();
int land_name_len = mMsg_Get_Length_String(land_name, LAND_NAME_SIZE);
new_start_idx = start_idx + land_name_len;
new_len = mMsg_MoveDataCut(data, start_idx + land_name_len, start_idx + command_len, len, FALSE);
mMsg_CopyString(&data[start_idx], land_name, land_name_len);
// This entire block can be removed in the English version
#ifndef IMPROVEMENTS
/* Leftover from JP to add 'むら' (mura) to the town name */
{
u8 mura_str[mMsg_FREE_STRING_LEN];
u8* mura_str_p = mura_str;
int mura_size;
mString_Load_StringFromRom(mura_str_p, sizeof(mura_str), 0x1E4);
mura_size = mMsg_Get_Length_String(mura_str_p, sizeof(mura_str));
new_len = mMsg_MoveDataCut(data, new_start_idx + mura_size, new_start_idx, new_len, FALSE);
mMsg_CopyString(&data[new_start_idx], mura_str_p, mura_size);
}
#endif
if (capitalize) {
data[start_idx] = mFont_small_to_capital(data[start_idx]);
}
return new_len;
}
extern int mMsg_CopyIslandName(u8* data, int start_idx, int len, u32 capitalize) {
int new_len;
int command_len = mFont_CodeSize_idx_get(data, start_idx);
u8* str = Save_Get(island).name;
int str_len = mMsg_Get_Length_String(str, mISL_ISLAND_NAME_LEN);
new_len = mMsg_MoveDataCut(data, start_idx + str_len, start_idx + command_len, len, FALSE);
mMsg_CopyString(&data[start_idx], str, str_len);
if (capitalize) {
data[start_idx] = mFont_small_to_capital(data[start_idx]);
}
return new_len;
}
extern int mMsg_CopyAmPm(mMsg_Window_c* msg_p, u8* data, int start_idx, int len) {
int new_len;
int command_len = mFont_CodeSize_idx_get(data, start_idx);
u8 str[15];
int str_len;
mString_Load_StringFromRom(str, sizeof(str), (msg_p->status_flags & mMsg_STATUS_FLAG_USE_AM) ? 1 : 2);
str_len = mMsg_Get_Length_String(str, sizeof(str));
new_len = mMsg_MoveDataCut(data, start_idx + str_len, start_idx + command_len, len, FALSE);
mMsg_CopyString(&data[start_idx], str, str_len);
return new_len;
}
extern int mMsg_CopyRamdomNumber2(u8* data, int start_idx, int len) {
int command_len = mFont_CodeSize_idx_get(data, start_idx);
u16 rng = get_random_timer(0, 100) % 100;
u8 str[2];
u8* str_p = str;
int str_len = mFont_UnintToString(str_p, 2, rng, 2, TRUE, FALSE, TRUE);
int new_len = mMsg_MoveDataCut(data, start_idx + str_len, start_idx + command_len, len, FALSE);
mMsg_CopyString(&data[start_idx], str_p, str_len);
return new_len;
}
extern int mMsg_CopyItem(mMsg_Window_c* msg_p, int str_no, u8* data, int start_idx, int len, int article, u32 capitalize) {
if (str_no < 0 || str_no >= mMsg_ITEM_STR_NUM) {
str_no = mMsg_ITEM_STR0;
}
{
int new_len;
int command_len = mFont_CodeSize_idx_get(data, start_idx);
u8* free_str_p = msg_p->item_str[str_no];
int free_str_len = mMsg_Get_Length_String(free_str_p, mMsg_FREE_STRING_LEN);
new_len = mMsg_MoveDataCut(data, start_idx + free_str_len, start_idx + command_len, len, FALSE);
mMsg_CopyString(&data[start_idx], free_str_p, free_str_len);
article = article != mIN_ARTICLE_NUM ? article : msg_p->item_str_article[str_no];
if (article != mIN_ARTICLE_NONE) {
u8 article_str[mIN_ITEM_NAME_LEN + 1];
mString_Load_StringFromRom(article_str, mIN_ITEM_NAME_LEN, mString_ARTICLE_START + article);
command_len = mMsg_Get_Length_String(article_str, mIN_ITEM_NAME_LEN);
article_str[command_len] = CHAR_SPACE;
new_len = mMsg_MoveDataCut(data, start_idx + command_len + 1, start_idx, new_len, FALSE);
mMsg_CopyString(&data[start_idx], article_str, command_len + 1);
}
if (capitalize) {
data[start_idx] = mFont_small_to_capital(data[start_idx]);
}
return new_len;
}
}
extern int mMsg_CopyMail(mMsg_Window_c* msg_p, int str_no, u8* data, int start_idx, int len, u32 capitalize) {
if (str_no < 0 || str_no >= mMsg_MAIL_STR_NUM) {
str_no = mMsg_MAIL_STR0;
}
{
int command_len = mFont_CodeSize_idx_get(data, start_idx);
u8* free_str_p = msg_p->mail_str[str_no];
int free_str_len = mMsg_Get_Length_String(free_str_p, mMsg_MAIL_STRING_LEN);
int new_len = mMsg_MoveDataCut(data, start_idx + free_str_len, start_idx + command_len, len, TRUE);
mMsg_CopyString(&data[start_idx], free_str_p, free_str_len);
if (capitalize) {
data[start_idx] = mFont_small_to_capital(data[start_idx]);
}
return new_len;
}
}
+132
View File
@@ -0,0 +1,132 @@
static int mMsg_Check_ScrollOrder(mMsg_Window_c* msg_p) {
return (chkTrigger(BUTTON_A) || chkTrigger(BUTTON_B));
}
static int mMsg_MsgTimeEnd_dec(mMsg_Window_c* msg_p) {
if (msg_p->end_timer == 0) {
return FALSE;
}
else if (msg_p->end_timer == 1) {
return TRUE;
}
else {
msg_p->end_timer--;
return FALSE;
}
}
static int mMsg_end_to_disappear(mMsg_Window_c* msg_p) {
if (mMsg_Change_request_main_index(msg_p, mMsg_INDEX_DISAPPEAR, 5)) {
mMsg_Clear_CursolIndex(msg_p);
mMsg_Unset_ForceNext(msg_p);
return TRUE;
}
return FALSE;
}
static void mMsg_request_main_index_fromNormal(mMsg_Window_c* msg_p, GAME* game) {
if (mMsg_MsgTimeEnd_dec(msg_p) && mMsg_Check_NextIndex_MsgTimeEndCode(msg_p)) {
mMsg_end_to_disappear(msg_p);
}
else if ((mMsg_Check_ScrollOrder(msg_p) || msg_p->force_next) && msg_p->lock_continue == FALSE) {
int last = FALSE;
if (mMsg_Check_NextIndex_ContinueCode(msg_p) && msg_p->continue_cancel_flag == FALSE) {
int continue_msg = msg_p->continue_msg_no;
if (continue_msg >= 0 && continue_msg < MSG_MAX && mMsg_ChangeMsgData(msg_p, continue_msg)) {
if (mMsg_request_main_cursol(msg_p, FALSE, 5) && msg_p->force_next == FALSE && mMsg_Check_NextIndex_SetSelectWindowCode(msg_p) == FALSE) {
if ((msg_p->status_flags & mMsg_STATUS_FLAG_NO_SE_PAGE_OKURI) == 0) {
mMsg_sound_PAGE_OKURI();
}
}
mMsg_Unset_ForceNext(msg_p);
mMsg_Set_continue_msg_num(msg_p, -1);
}
}
else if (
(mMsg_Check_NextIndex_ContinueCode(msg_p) && msg_p->continue_cancel_flag) ||
(last = mMsg_Check_NextIndex_LastCode(msg_p)) || // hate this but it works
mMsg_Check_NextIndex_MsgTimeEndCode(msg_p)
) {
if ((msg_p->status_flags & mMsg_STATUS_FLAG_IDLING_NOW) == 0) {
if (last && (msg_p->status_flags & mMsg_STATUS_FLAG_IDLING_REQ)) {
msg_p->status_flags |= mMsg_STATUS_FLAG_IDLING_NOW;
}
else {
mMsg_end_to_disappear(msg_p);
}
}
}
else if (mMsg_request_main_cursol(msg_p, FALSE, 5)) {
if (
msg_p->force_next == FALSE &&
mMsg_Check_NextIndex_SetSelectWindowCode(msg_p) == FALSE &&
(msg_p->status_flags & mMsg_STATUS_FLAG_NO_SE_PAGE_OKURI) == 0
) {
mMsg_sound_PAGE_OKURI();
}
mMsg_Unset_ForceNext(msg_p);
}
}
}
static void mMsg_Set_display_button_turn_color(mMsg_Window_c* msg_p, GAME* game) {
f32* timer = &msg_p->continue_button_timer;
f32 target;
(*timer) += 1.0f;
if (*timer >= mMsg_BUTTON_TURN_TIME) {
*timer = 0.0f;
}
target = (*timer - mMsg_BUTTON_TURN_TIME * 0.5f) / (mMsg_BUTTON_TURN_TIME * 0.5f);
target = target <= 0.0f ? 1.0f + target : 1.0f - target;
if (target < 0.0f) {
target = 0.0f;
}
else if (target > 1.0f) {
target = 1.0f;
}
msg_p->continue_button_color.a = (int)(target * 255.0f);
}
static void mMsg_Main_Normal(mMsg_Window_c* msg_p, GAME* game) {
mMsg_Set_display_button_turn_color(msg_p, game);
mMsg_request_main_index_fromNormal(msg_p, game);
mMsg_MainSetup_Window(msg_p, game);
if (msg_p->main_index != mMsg_INDEX_NORMAL) {
msg_p->status_flags &= ~mMsg_STATUS_FLAG_NO_SE_PAGE_OKURI;
}
}
static void mMsg_MainSetup_Normal(mMsg_Window_c* msg_p, GAME* game) {
mMsg_Request_MainNormal_Data_c* normal_data = &msg_p->request_data.request_main_normal;
int wait_flag = normal_data->wait_flag;
msg_p->main_index = mMsg_INDEX_NORMAL;
msg_p->draw_flag = TRUE;
msg_p->requested_main_index = -1;
msg_p->requested_priority = 4;
msg_p->status_flags &= ~mMsg_STATUS_FLAG_IDLING_NOW;
if (wait_flag != TRUE) {
msg_p->continue_button_timer = 0.0f;
msg_p->continue_button_color.a = 0;
if (msg_p->end_timer == 0) {
msg_p->show_continue_button = TRUE;
}
else {
msg_p->show_continue_button = FALSE;
}
msg_p->cancel_flag = FALSE;
}
}
+358
View File
@@ -0,0 +1,358 @@
extern int mMsg_sound_voice_get(int code) {
static u8 voice_array[TOTAL_CHARS] = {
0x85, 0x85, 0x5D, 0x5D, 0x5D, 0x5D, 0x5D, 0x5D, 0x5F, 0x61, 0x61, 0x61, 0x61, 0x65, 0x65, 0x65,
0x65, 0x60, 0x6A, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x85, 0x71, 0x71, 0x71, 0x71, 0x5E, 0x6C, 0x5D,
0x81, 0x83, 0x85, 0x5D, 0x5D, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x80,
0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x85, 0x85, 0x85, 0x85, 0x85, 0x82,
0x85, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B,
0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x5D, 0x85, 0x5D, 0x5D, 0x85,
0x5F, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B,
0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x61, 0x61, 0x61, 0x61, 0xFF,
0xFF, 0x65, 0x65, 0x65, 0x65, 0x86, 0x60, 0x6A, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x85, 0x71, 0x71,
0x85, 0x71, 0x71, 0x75, 0x75, 0x6C, 0x75, 0x85, 0x85, 0x5D, 0x6B, 0x85, 0x85, 0x85, 0x85, 0x85,
0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85,
0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85,
0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85,
0x85, 0x85, 0x81, 0x81, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85,
0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85,
0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x81
};
if (code == CHAR_CONTROL_CODE || code == CHAR_MESSAGE_TAG) {
return -1;
}
return voice_array[code];
}
extern int mMsg_sound_voice_get_for_editor(int code) {
int sound = mMsg_sound_voice_get(code);
switch (sound) {
case 0x80:
case 0x82:
case 0x83:
case 0x85:
return 0x86;
default:
return sound;
}
return sound;
}
static int mMsg_sound_voice_get2(int code) {
if (code == CHAR_NEW_LINE) {
return 0x84;
}
return mMsg_sound_voice_get(code);
}
static int mMsg_check_sound_special(mMsg_Window_c* msg_p) {
int msg_no = msg_p->msg_data->msg_no;
return (msg_no >= 0x1743 && msg_no <= 0x1756) || /* Event starting */
(msg_no >= 0x1799 && msg_no <= 0x17AC) || /* Event ending */
(msg_no >= 0x3A8A && msg_no <= 0x3AF0); /* Dial-a-Psychic */
}
static int mMsg_check_sound_shasho(mMsg_Window_c* msg_p) {
int msg_no = msg_p->msg_data->msg_no;
return (msg_no >= 0x35AF && msg_no <= 0x35BE);
}
static int mMsg_check_sound_animal(mMsg_Window_c* msg_p) {
if ((msg_p->status_flags & mMsg_STATUS_FLAG_VOICE_CLICK) != 0) {
return FALSE;
}
return (msg_p->show_actor_name || mMsg_check_sound_special(msg_p) || mMsg_check_sound_shasho(msg_p));
}
static int mMsg_sound_npc_id_get(mMsg_Window_c* msg_p) {
int id = 0;
ACTOR* actor = msg_p->client_actor_p;
if (actor != NULL && actor->part == ACTOR_PART_NPC) {
id = ((NPC_ACTOR*)actor)->talk_info.npc_voice_id;
}
return id;
}
static void mMsg_sound_voice_entry(mMsg_Window_c* msg_p, int voice_sfx_idx, u8 voice_no, s16 voice_anm_id) {
if (voice_sfx_idx != msg_p->voice_sfx_idx && voice_sfx_idx != msg_p->end_text_cursor_idx) {
msg_p->voice_sfx_idx = voice_sfx_idx;
if ((msg_p->status_flags & mMsg_STATUS_FLAG_VOICE_ENTRY) != 0) {
u8* msg_data = msg_p->msg_data->text_buf.data;
int code_size = mMsg_Set_SizeCode(msg_p, voice_sfx_idx);
int voice3_idx;
if (msg_data[voice_sfx_idx + code_size] == CHAR_NEW_LINE) {
voice3_idx = 0xFF;
}
else {
voice3_idx = mMsg_sound_voice_get2(msg_data[voice_sfx_idx + code_size]);
if (voice3_idx < 0) {
voice3_idx = 0xFF;
}
}
msg_p->voice2_idx = voice_no;
msg_p->voice3_idx = voice3_idx;
msg_p->status_flags |= mMsg_STATUS_FLAG_18;
}
else if (voice_no != 129) {
msg_p->free_str_color_idx[3] = 1;
msg_p->voice_idx = voice_no;
msg_p->voice2_idx = 0xFF;
msg_p->voice3_idx = 0xFF;
msg_p->animal_voice_idx = voice_anm_id;
msg_p->status_flags |= mMsg_STATUS_FLAG_VOICE_ENTRY;
}
}
}
static void mMsg_sound_voice_endcode_set(mMsg_Window_c* msg_p) {
int npc_id = mMsg_sound_npc_id_get(msg_p);
sAdo_VoiceSe(0x84, 0xFF, 0xFF, npc_id, 32, 0);
msg_p->free_str_color_idx[3] = 0;
msg_p->status_flags &= ~(mMsg_STATUS_FLAG_18 | mMsg_STATUS_FLAG_VOICE_ENTRY);
}
static int mMsg_sound_CodeVoice(mMsg_Window_c* msg_p, int idx) {
u8* data = msg_p->msg_data->text_buf.data;
int voice_id = mMsg_sound_voice_get2(data[idx]);
if (voice_id < 0) {
return FALSE;
}
else if ((msg_p->status_flags & mMsg_STATUS_FLAG_SOUND_CUT) != 0) {
int voice_mode = Save_Get(config).voice_mode;
if (voice_mode != Config_VOICE_MODE_SILENT) {
sAdo_SysTrgStart(0x54);
}
mMsg_sound_voice_endcode_set(msg_p);
return FALSE;
}
else {
int npc_id = mMsg_sound_npc_id_get(msg_p);
mMsg_sound_voice_entry(msg_p, idx, voice_id, npc_id);
return voice_id != 0x81 &&
voice_id != 0x83 &&
voice_id != 0x82 &&
voice_id != 0x85 &&
voice_id != 0x80;
}
}
static void mMsg_sound_PAGE_OKURI() {
sAdo_SysTrgStart(0xB);
}
static void mMsg_sound_ZOOMUP() {
sAdo_SysTrgStart(0x8004);
}
static void mMsg_sound_ZOOMDOWN_SHORT(mMsg_Window_c* msg_p) {
if ((msg_p->status_flags & mMsg_STATUS_FLAG_NO_ZOOMDOWN) == 0) {
sAdo_SysTrgStart(0x8005);
}
}
static void mMsg_sound_ZOOMDOWN_LONG(mMsg_Window_c* msg_p) {
if ((msg_p->status_flags & mMsg_STATUS_FLAG_NO_ZOOMDOWN) == 0) {
sAdo_SysTrgStart(0x8015);
}
}
static u8 Sound_Now_MessageSpeed = 1;
static void mMsg_sound_MessageSpeedForce(f32 timer) {
u8 int_timer = (int)timer;
int_timer++;
if (int_timer > 0) {
if (sAdo_MessageSpeedGet() != int_timer) {
sAdo_MessageSpeed(int_timer);
}
Sound_Now_MessageSpeed = int_timer;
}
else {
sAdo_MessageSpeed(1);
Sound_Now_MessageSpeed = 1;
}
}
static void mMsg_sound_MessageSpeedClear(int speed) {
if (Sound_Now_MessageSpeed != 1) {
Sound_Now_MessageSpeed = 1;
}
else if (sAdo_MessageSpeedGet() != 1) {
sAdo_MessageSpeed(speed);
}
}
static void mMsg_sound_MessageStatus(u8 status) {
sAdo_MessageStatus(status);
}
static u8 mMsg_bgm_num[mFont_BGM_NUM] = {
255,
47,
48,
49,
50,
66,
255,
78,
122
};
static u16 mMsg_bgm_stop[mFont_BGM_STOP_TYPE_NUM] = {
0x168,
0,
0x321C
};
static void mMsg_sound_bgm_make(int bgm_no, int stop_type) {
if (bgm_no == mFont_BGM_QUIET) {
mBGMPsComp_make_ps_quiet(mMsg_bgm_stop[stop_type]);
}
else if (bgm_no == 6) {
mBGMPsComp_make_ps_fc_quietField(mMsg_bgm_stop[stop_type]);
}
else {
mBGMPsComp_make_ps_demo(mMsg_bgm_num[bgm_no], mMsg_bgm_stop[stop_type]);
}
}
static void mMsg_sound_bgm_delete(int bgm_no, int stop_type) {
if (bgm_no == mFont_BGM_QUIET) {
mBGMPsComp_delete_ps_quiet();
}
else {
mBGMPsComp_delete_ps_demo(mMsg_bgm_num[bgm_no], mMsg_bgm_stop[stop_type]);
}
}
static void mMsg_sound_sound_trg_sys(int se_no) {
static u16 mMsg_se_num[mFont_SE_NUM] = {
0x1050, 0x012e, 0x012f, 0x0130, 0x0131, 0x0427, 0x0428
};
if (se_no != 4 && se_no != 3) {
sAdo_SysTrgStart(mMsg_se_num[se_no]);
}
}
static u8 mMsg_sound_voice_mode_get(mMsg_Window_c* msg_p) {
int mode_type = Save_Get(config).voice_mode;
u8 mode;
if ((msg_p->status_flags & mMsg_STATUS_FLAG_VOICE_SILENT) != 0) {
mode_type = Config_VOICE_MODE_SILENT;
}
if (mMsg_check_sound_animal(msg_p)) {
static u8 mode_table[Config_VOICE_MODE_NUM] = { VOICE_MODE_ANIMALESE, VOICE_MODE_CLICK, VOICE_MODE_SILENT };
mode = mode_table[mode_type];
}
else if (mode_type == Config_VOICE_MODE_SILENT) {
mode = VOICE_MODE_SILENT;
}
else {
mode = VOICE_MODE_CLICK;
}
return mode;
}
static void mMsg_sound_voice_mode(mMsg_Window_c* msg_p) {
sAdo_SetVoiceMode(mMsg_sound_voice_mode_get(msg_p));
}
extern void mMsg_sound_spec_change_voice_force(mMsg_Window_c* msg_p) {
int spec;
if (mMsg_check_sound_special(msg_p)) {
spec = 4;
}
else {
spec = mNpc_GetNpcSoundSpec(msg_p->client_actor_p);
}
sAdo_SpecChange(spec);
msg_p->status_flags |= mMsg_STATUS_FLAG_SPEC_VOICE;
msg_p->spec = spec;
}
extern int mMsg_sound_spec_change_voice(mMsg_Window_c* msg_p) {
if (mMsg_sound_voice_mode_get(msg_p) == VOICE_MODE_ANIMALESE) {
mMsg_sound_spec_change_voice_force(msg_p);
return TRUE;
}
return FALSE;
}
static void mMsg_sound_spec_change_scene(mMsg_Window_c* msg_p) {
if ((msg_p->status_flags & mMsg_STATUS_FLAG_SPEC_VOICE) != 0) {
msg_p->status_flags &= ~mMsg_STATUS_FLAG_SPEC_VOICE;
}
}
static void mMsg_sound_spec_change_true(mMsg_Window_c* msg_p) {
ACTOR* actor = msg_p->client_actor_p;
if (actor != NULL && actor->part == ACTOR_PART_NPC) {
const mActor_name_t npc_id = actor->npc_id;
if (npc_id == SP_NPC_MAMEDANUKI0 || npc_id == SP_NPC_MAMEDANUKI1) {
sAdo_SpecChange(msg_p->spec);
}
}
}
static void mMsg_sound_spec_change_false(mMsg_Window_c* msg_p) {
ACTOR* actor = msg_p->client_actor_p;
if (actor != NULL && actor->part == ACTOR_PART_NPC) {
const mActor_name_t npc_id = actor->npc_id;
if (npc_id == SP_NPC_MAMEDANUKI0 || npc_id == SP_NPC_MAMEDANUKI1) {
sAdo_SpecChange(7);
}
}
}
extern void mMsg_sound_set_voice_click(mMsg_Window_c* msg_p) {
msg_p->status_flags |= mMsg_STATUS_FLAG_VOICE_CLICK;
}
extern void mMsg_sound_set_voice_silent(mMsg_Window_c* msg_p, int update_mode) {
msg_p->status_flags |= mMsg_STATUS_FLAG_VOICE_SILENT;
if (update_mode) {
mMsg_sound_voice_mode(msg_p);
}
}
extern void mMsg_sound_unset_voice_silent(mMsg_Window_c* msg_p, int update_mode) {
msg_p->status_flags &= ~mMsg_STATUS_FLAG_VOICE_SILENT;
if (update_mode) {
mMsg_sound_voice_mode(msg_p);
}
}
+18
View File
@@ -0,0 +1,18 @@
static void mMsg_Main_Wait(mMsg_Window_c* msg_p, GAME* game) {
mMsg_MainSetup_Window(msg_p, game);
}
static void mMsg_MainSetup_Wait(mMsg_Window_c* msg_p, GAME* game) {
mMsg_Request_MainWait_Data_c* request_data = &msg_p->request_data.request_main_wait;
mMsg_MainWait_Data_c* main_data = &msg_p->main_data.main_wait;
main_data->last_main_index = request_data->last_main_index;
msg_p->main_index = mMsg_INDEX_WAIT;
msg_p->draw_flag = FALSE;
msg_p->window_scale = 0.0f;
msg_p->text_scale = 0.0f;
msg_p->timer = 0.0f;
msg_p->requested_main_index = -1;
msg_p->requested_priority = 4;
msg_p->status_flags &= ~mMsg_STATUS_FLAG_NO_ZOOMDOWN;
}
+4 -4
View File
@@ -379,7 +379,7 @@ void Game_play_fbdemo_proc(GAME_PLAY* play){
void play_cleanup(GAME* game){
GAME_PLAY* play = (GAME_PLAY*)game;
mMsg_dt(play);
mMsg_dt(game);
banti_dt();
play->game.graph->taskEndCallback = NULL;
@@ -515,7 +515,7 @@ void play_init(GAME* game){
mMmd_MakeMuseumDisplayData();
Actor_info_ct(&play->game, &play->actor_info, play->player_data);
play->draw_chk_proc = none_proc1;
mMsg_ct(play);
mMsg_ct(game);
mEv_2nd_init(&play->event);
mTD_player_keydata_init(play);
Balloon_init(play);
@@ -566,7 +566,7 @@ void Game_play_move_fbdemo_not_move(GAME_PLAY* play){
play->game.doing_point = 1;
mCoBG_CalcTimerDecalCircle();
play->game.doing_point = 2;
mMsg_Main(play);
mMsg_Main((GAME*)play);
}
else{
mVibctl_set_force_stop(2);
@@ -774,7 +774,7 @@ int makeBumpTexture(GAME_PLAY* play, GRAPH* graph1, GRAPH* graph2){
if((GETREG(HREG, 80) != 10) || (GETREG(HREG, 85) != 0)){
Actor_info_draw_actor(play, &play->actor_info);
Camera2_draw(play);
mMsg_Draw(play);
mMsg_Draw((GAME*)play);
}
if((GETREG(HREG, 80) != 10) || (GETREG(HREG, 93) != 0)){
+2 -2
View File
@@ -467,12 +467,12 @@ static int sChk_PoliceBox_c_sub(PoliceBox_c* police_box, int depth) {
static int sChk_Config_c_sub(Config_c* config, int depth) {
int res = FALSE;
if (config->sound_mode > Config_SOUND_MODE_3) {
if (config->sound_mode > Config_SOUND_MODE_NUM) {
mFRm_ERRORLINE(1775);
res = TRUE;
}
if (config->voice_mode > Config_VOICE_MODE_3) {
if (config->voice_mode > Config_VOICE_MODE_NUM) {
mFRm_ERRORLINE(1789);
res = TRUE;
}