diff --git a/config/rel_slices.yml b/config/rel_slices.yml index c93259de..94d80748 100644 --- a/config/rel_slices.yml +++ b/config/rel_slices.yml @@ -138,6 +138,12 @@ zurumode.c: sys_ucode.c: .text: [0x8040F008, 0x8040F048] .data: [0x8065FA30, 0x8065FA40] +ac_animal_logo.c: + .text: [0x804104AC, 0x804117D4] + .rodata: [0x80643918, 0x80643A88] + .data: [0x8065FB68, 0x8065FBA8] +ac_animal_logo_misc.c: + .text: [0x804117D4, 0x80411A60] ac_set_manager.c: .text: [0x80496AB8, 0x80496F50] .rodata: [0x80644DB8, 0x80644DC8] diff --git a/include/Famicom/famicom.h b/include/Famicom/famicom.h index d72ed0ac..9163fdc7 100644 --- a/include/Famicom/famicom.h +++ b/include/Famicom/famicom.h @@ -70,6 +70,7 @@ typedef struct famicom_common_s { typedef u8 (*FAMICOM_GETSAVECHAN_PROC)(int* player_no, int* slot_card_result); extern void famicom_setCallback_getSaveChan(FAMICOM_GETSAVECHAN_PROC getSaveChan_proc); +extern int famicom_mount_archive_end_check(); #ifdef __cplusplus } diff --git a/include/ac_animal_logo.h b/include/ac_animal_logo.h new file mode 100644 index 00000000..ceb0c8eb --- /dev/null +++ b/include/ac_animal_logo.h @@ -0,0 +1,91 @@ +#ifndef AC_ANIMAL_LOGO_H +#define AC_ANIMAL_LOGO_H + +#include "types.h" +#include "game.h" +#include "m_actor.h" +#include "m_lib.h" +#include "c_keyframe.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void (*aAL_DATA_INIT_PROC)(GAME_PLAY*); + +typedef struct animal_logo_clip_s { + aAL_DATA_INIT_PROC data_init_proc; +} aAL_Clip_c; + +#define aAL_BACK_FADEIN_RATE 20 +#define aAL_BACK_FADEIN_MAX 220 + +#define aAL_TIMER 60 +#define aAL_FADEOUT_TIMER 26 + +#define aAL_COPYRIGHT_ALPHA_RATE 63 + +typedef struct actor_animal_logo_s ANIMAL_LOGO_ACTOR; + +typedef void (*ANIMAL_LOGO_ACTION_PROC)(ANIMAL_LOGO_ACTOR*, GAME*); + +typedef struct logo_skeleton_info_s { + cKF_SkeletonInfo_R_c skeleton; + s_xyz* work_area_p; + s_xyz* morph_area_p; +} aAL_SkeletonInfo_c; + +struct actor_animal_logo_s { + ACTOR actor_class; + + int action; + ANIMAL_LOGO_ACTION_PROC action_proc; + + aAL_SkeletonInfo_c animal; + aAL_SkeletonInfo_c cros; + aAL_SkeletonInfo_c sing; + + s_xyz animal_work_area[22]; + s_xyz animal_morph_area[22]; + + s_xyz cros_work_area[15]; + s_xyz cros_morph_area[15]; + + s_xyz sing_work_area[15]; + s_xyz sing_morph_area[15]; + + s16 back_opacity; + int copyright_opacity; + f32 press_start_opacity; + s16 start_opacity_timer; + int title_timer; + int titledemo_no; + + int unused_56C[6]; +}; + +enum { + aAL_ACTION_IN, + aAL_ACTION_BACK_FADE_IN, + aAL_ACTION_START_KEY_CHK_START, + aAL_ACTION_GAME_START, + aAL_ACTION_FADE_OUT_START, + aAL_ACTION_OUT, + aAL_ACTION_6, + + aAL_ACTION_NUM +}; + +extern ACTOR_PROFILE Animal_Logo_Profile; + +// TODO: these are private but due to the way our build system works, +// we must expose them to get them in a separate TU. +extern void flash_rom_and_player_info_clear(); +extern int decide_next_scene_no(); +extern void title_action_data_init_start_select(GAME_PLAY* play); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/c_keyframe.h b/include/c_keyframe.h index 873b92b0..7f1a7da0 100644 --- a/include/c_keyframe.h +++ b/include/c_keyframe.h @@ -103,7 +103,7 @@ extern void cKF_SkeletonInfo_R_init_standard_repeat_morph(cKF_SkeletonInfo_R_c* extern void cKF_SkeletonInfo_R_init(cKF_SkeletonInfo_R_c* keyframe, cKF_Skeleton_R_c* skeleton, cKF_Animation_R_c* animation, f32 start_frame, f32 end_frame, f32 current_frame, f32 frame_speed, f32 morph_counter,int mode,s_xyz* rotation_diff_table); -extern int cKF_Animation_R_play(cKF_SkeletonInfo_R_c* keyframe); +extern int cKF_SkeletonInfo_R_play(cKF_SkeletonInfo_R_c* keyframe); extern void cKF_Si3_draw_SV_R_child(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int* joint_num, cKF_draw_callback prerender_callback, cKF_draw_callback postrender_callback, void* arg, Mtx** mtxpp); extern void cKF_Si3_draw_R_SV(GAME* game, cKF_SkeletonInfo_R_c* keyframe, Mtx* mtxp, cKF_draw_callback prerender_callback, cKF_draw_callback postrender_callback, void* arg); diff --git a/include/m_card.h b/include/m_card.h index 738fb6b8..832c1869 100644 --- a/include/m_card.h +++ b/include/m_card.h @@ -10,9 +10,11 @@ extern "C" { extern u8 mCD_GetThisLandSlotNo_code(int* player_no, int* slot_card_results); extern void mCD_save_data_aram_malloc(); +extern void mCD_set_aram_save_data(); extern void mCD_PrintErrInfo(gfxprint_t* gfxprint); extern void mCD_InitAll(); +extern void mCD_LoadLand(); #ifdef __cplusplus } diff --git a/include/m_clip.h b/include/m_clip.h index 0d7eea39..bba386d6 100644 --- a/include/m_clip.h +++ b/include/m_clip.h @@ -5,6 +5,7 @@ #include "ac_gyoei_h.h" #include "ac_insect_h.h" #include "ac_structure.h" +#include "ac_animal_logo.h" #ifdef __cplusplus extern "C" { @@ -18,7 +19,9 @@ typedef struct clip_s { /* 0x08C */ aSTR_Clip_c* structure_clip; /* 0x090 */ void* _090[(0x0AC - 0x090) / sizeof(void*)]; /* 0x0AC */ aGYO_Clip_c* gyo_clip; - /* 0x0B0 */ void* _0B0[(0x104 - 0x0B0) / sizeof(void*)]; + /* 0x0B0 */ void* _0B0[(0x0DC - 0x0B0) / sizeof(void*)]; + /* 0x0DC */ aAL_Clip_c* animal_logo_clip; + /* 0x0E0 */ void* _0E0[(0x104 - 0x0E0) / sizeof(void*)]; } Clip_c; #ifdef __cplusplus diff --git a/include/m_fbdemo_fade.h b/include/m_fbdemo_fade.h index 6c017995..f389c7cf 100644 --- a/include/m_fbdemo_fade.h +++ b/include/m_fbdemo_fade.h @@ -20,7 +20,7 @@ extern fbdemo_fade* fbdemo_fade_init(fbdemo_fade*); extern void fbdemo_fade_move(fbdemo_fade*, int); extern void fbdemo_fade_startup(fbdemo_fade*); extern void fbdemo_fade_settype(fbdemo_fade*, int); -extern void fbdemo_fade_setcolor_rgba8888(fbdemo_fade*, u32); +extern void fbdemo_fade_setcolor_rgba8888(fbdemo_fade* this, u32 color); extern u8 fbdemo_fade_is_finish(fbdemo_fade*); #endif \ No newline at end of file diff --git a/include/m_fbdemo_triforce.h b/include/m_fbdemo_triforce.h index 1824a8b9..f4653ca8 100644 --- a/include/m_fbdemo_triforce.h +++ b/include/m_fbdemo_triforce.h @@ -24,7 +24,7 @@ extern void fbdemo_triforce_move(fbdemo_triforce*, int); extern void fbdemo_triforce_draw(fbdemo_triforce*, Gfx**); extern s8 fbdemo_triforce_is_finish(fbdemo_triforce*); extern void fbdemo_triforce_settype(fbdemo_triforce*, int); -extern void fbdemo_fade_setcolor_rgba8888(void); +extern void fbdemo_triforce_setcolor_rgba8888(void); #endif \ No newline at end of file diff --git a/include/m_npc.h b/include/m_npc.h index a4c5cabf..b54b0078 100644 --- a/include/m_npc.h +++ b/include/m_npc.h @@ -193,6 +193,10 @@ extern void mNpc_CopyAnimalPersonalID(AnmPersonalID_c* dst, AnmPersonalID_c* src extern AnmPersonalID_c* mNpc_GetOtherAnimalPersonalID(AnmPersonalID_c* ids, int num_ids); extern void mNpc_ClearEventNpc(); extern void mNpc_ClearMaskNpc(); +extern int mNpc_SearchAnimalinfo(Animal_c* animal, mActor_name_t npc_name, int count); +extern int mNpc_RegistEventNpc(mActor_name_t actor_name, mActor_name_t tex_name, mActor_name_t npc_name, mActor_name_t cloth_name); +extern void mNpc_ClearAnimalInfo(Animal_c* animal_p); +extern Animal_c* mNpc_GetInAnimalP(); extern void mNpc_PrintRemoveInfo(gfxprint_t* gfxprint); extern void mNpc_PrintFriendship_fdebug(gfxprint_t* gfxprint); diff --git a/include/m_play.h b/include/m_play.h index e931429f..343882c1 100644 --- a/include/m_play.h +++ b/include/m_play.h @@ -9,6 +9,7 @@ #include "m_submenu.h" #include "m_pause.h" #include "m_field_info.h" +#include "m_fbdemo_wipe.h" #include "m_play_h.h" #ifdef __cplusplus @@ -29,16 +30,21 @@ struct game_play_s { /* 0x1DA0 */ pause_t pause; /* 0x1DA8 */ Actor_info actor_info; /* 0x1DEC */ Submenu submenu; - /* 0x1FA4 */ u8 _1FA4[0x200C - 0x1FA4]; + /* 0x1FA4 */ u8 _1FA4[0x2008 - 0x1FA4]; + /* 0x2008 */ int next_scene_no; /* 0x200C */ MtxF matrix; /* 0x204C */ u8 _204C[0x20D0-0x204C]; /* 0x20D0 */ u8 fb_fade_type; /* 0x20D1 */ u8 fb_wipe_type; /* 0x20D2 */ u8 fb_mode; /* 0x20D3 */ u8 fb_wipe_mode; - /* 0x20D4 */ u8 _20D4[0x2600 - 0x20D4]; + /* 0x20D4 */ //int _20D4; + /* 0x20D8 */ fbdemo_wipe fbdemo_wipe; + /* 0x2318 */ fbdemo_fade color_fade; + /* 0x2328 */ u8 _2328[0x2600 - 0x2328]; }; + extern void play_init(GAME_PLAY* play); extern void play_cleanup(GAME_PLAY* play); diff --git a/include/m_scene_table.h b/include/m_scene_table.h index 599a978e..dfc074f5 100644 --- a/include/m_scene_table.h +++ b/include/m_scene_table.h @@ -21,8 +21,6 @@ enum field_draw_type { there may be a better place for this */ -#define SCENE_INVALID -1 - enum scene_table { SCENE_TEST1, SCENE_TEST2, diff --git a/include/m_time.h b/include/m_time.h index 47f08660..c9e7e716 100644 --- a/include/m_time.h +++ b/include/m_time.h @@ -71,7 +71,18 @@ typedef struct time_calendar_term_s { s16 bgitem_bank; } mTM_calendar_term_t; -extern void mTM_set_renew_time(lbRTC_ymd_t* renew_time, lbRTC_time_c* rtc_time); +extern void mTM_set_season_com(int term_idx); +extern void mTM_set_season(); +extern int mTM_check_renew_time(u8 renew_flag); +extern void mTM_off_renew_time(u8 renew_flag); +extern void mTM_set_renew_is(); +extern void mTM_set_renew_time(lbRTC_ymd_t* renew_time, const lbRTC_time_c* time); +extern void mTM_ymd_2_time(lbRTC_time_c* time, const lbRTC_ymd_t* ymd); +extern void mTM_renewal_renew_time(); +extern void mTM_clear_renew_is(); +extern void mTM_rtcTime_limit_check(); +extern void mTM_time(); +extern void mTM_time_init(); extern const lbRTC_time_c mTM_rtcTime_clear_code; extern const lbRTC_ymd_t mTM_rtcTime_ymd_clear_code; @@ -80,7 +91,6 @@ extern const lbRTC_time_c mTM_rtcTime_default_code; #define mTM_IsTimeCleared(time) (lbRTC_IsEqualTime((time), &mTM_rtcTime_clear_code, lbRTC_CHECK_ALL) == TRUE) #define mTM_AreTimesEqual(t0, t1) (lbRTC_IsEqualTime(t0, t1, lbRTC_CHECK_ALL)) -extern void mTM_set_season(); #ifdef __cplusplus } diff --git a/rel/ac_animal_logo.c b/rel/ac_animal_logo.c new file mode 100644 index 00000000..9f3a717b --- /dev/null +++ b/rel/ac_animal_logo.c @@ -0,0 +1,637 @@ +#include "ac_animal_logo.h" + +#include "m_common_data.h" +#include "m_malloc.h" +#include "m_event.h" +#include "m_play.h" +#include "m_bgm.h" +#include "m_npc.h" +#include "libc64/qrand.h" +#include "m_name_table.h" +#include "padmgr.h" +#include "audio.h" +#include "Famicom/famicom.h" +#include "m_land.h" +#include "m_titledemo.h" +#include "m_card.h" +#include "m_rcp.h" +#include "m_cpak.h" +#include "sys_matrix.h" +#include "m_time.h" +#include "m_font.h" +#include "libultra/libultra.h" +#include "m_flashrom.h" + +#define G_CC_TITLE PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, 0, TEXEL0, 0 +#define G_CC_TM 0, 0, 0, PRIMITIVE, 0, 0, 0, TEXEL0 +#define G_CC_BACK 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0 +#define G_CC_PRESS_START PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, 0, TEXEL0, 0 + +#define TITLE_WIDTH 64 +#define TITLE_HEIGHT 16 + +extern u8 log_win_nintendo1_tex[]; +extern u8 log_win_nintendo2_tex[]; +extern u8 log_win_nintendo3_tex[]; + +extern Gfx logo_us_tm_model[]; + +extern Gfx logo_us_backA_model[]; +extern Gfx logo_us_backB_model[]; +extern Gfx logo_us_backC_model[]; +extern Gfx logo_us_backD_model[]; + +extern u8 log_win_logo3_tex[]; +extern u8 log_win_logo4_tex[]; + +extern cKF_Skeleton_R_c cKF_bs_r_logo_us_animal; +extern cKF_Skeleton_R_c cKF_bs_r_logo_us_cros; +extern cKF_Skeleton_R_c cKF_bs_r_logo_us_sing; + +static void aAL_actor_ct(ACTOR* actor, GAME* game); +static void aAL_actor_dt(ACTOR* actor, GAME* game); +static void aAL_actor_move(ACTOR* actor, GAME* game); +static void aAL_actor_draw(ACTOR* actor, GAME* game); + +ACTOR_PROFILE Animal_Logo_Profile = { + 0xAB, // TODO: replace with enum + ACTOR_PART_BG, + ACTOR_STATE_NO_MOVE_WHILE_CULLED | ACTOR_STATE_NO_DRAW_WHILE_CULLED, + EMPTY_NO, + ACTOR_OBJ_BANK_3, + sizeof(ANIMAL_LOGO_ACTOR), + &aAL_actor_ct, + &aAL_actor_dt, + &aAL_actor_move, + &aAL_actor_draw, + NULL +}; + + +// TODO: once proper building is possible, fix this +//#include "../rel/ac_animal_logo_misc.c" + +static void aAL_setupAction(ANIMAL_LOGO_ACTOR* actor, GAME* game, int action); +static void aAL_title_decide_p_sel_npc(); + +static void aAL_actor_ct(ACTOR* actor, GAME* game) { + ANIMAL_LOGO_ACTOR* logo_actor = (ANIMAL_LOGO_ACTOR*)actor; + GAME_PLAY* play = (GAME_PLAY*)game; + Clip_c* clip = Common_GetPointer(clip); + aAL_SkeletonInfo_c* skeleton_info; + + if (clip->animal_logo_clip == NULL) { + clip->animal_logo_clip = (aAL_Clip_c*)zelda_malloc(sizeof(aAL_Clip_c)); + clip->animal_logo_clip->data_init_proc = &title_action_data_init_start_select; + } + + skeleton_info = &logo_actor->animal; + skeleton_info->work_area_p = logo_actor->animal_work_area; + skeleton_info->morph_area_p = logo_actor->animal_morph_area; + cKF_SkeletonInfo_R_ct(&skeleton_info->skeleton, &cKF_bs_r_logo_us_animal, NULL, skeleton_info->work_area_p, skeleton_info->morph_area_p); + + skeleton_info = &logo_actor->cros; + skeleton_info->work_area_p = logo_actor->cros_work_area; + skeleton_info->morph_area_p = logo_actor->cros_morph_area; + cKF_SkeletonInfo_R_ct(&skeleton_info->skeleton, &cKF_bs_r_logo_us_cros, NULL, skeleton_info->work_area_p, skeleton_info->morph_area_p); + + + skeleton_info = &logo_actor->sing; + skeleton_info->work_area_p = logo_actor->sing_work_area; + skeleton_info->morph_area_p = logo_actor->sing_morph_area; + cKF_SkeletonInfo_R_ct(&skeleton_info->skeleton, &cKF_bs_r_logo_us_sing, NULL, skeleton_info->work_area_p, skeleton_info->morph_area_p); + + aAL_setupAction(logo_actor, (GAME*)play, aAL_ACTION_IN); +} + +static void aAL_actor_dt(ACTOR* actor, GAME* game) { + ANIMAL_LOGO_ACTOR* logo_actor = (ANIMAL_LOGO_ACTOR*)actor; + + if (Common_Get(clip.animal_logo_clip) != NULL) { + zelda_free(Common_Get(clip.animal_logo_clip)); + Common_Set(clip.animal_logo_clip, NULL); + } + + if (mEv_CheckTitleDemo() != -1) { + mEv_SetTitleDemo(0); + } + + cKF_SkeletonInfo_R_dt(&logo_actor->animal.skeleton); + cKF_SkeletonInfo_R_dt(&logo_actor->cros.skeleton); + cKF_SkeletonInfo_R_dt(&logo_actor->sing.skeleton); + + if (mFRm_CheckSaveData() == TRUE) { + aAL_title_decide_p_sel_npc(); + } +} + +static void aAL_title_game_data_init_start_select(ANIMAL_LOGO_ACTOR* actor, GAME* game) { + GAME_PLAY* play = (GAME_PLAY*)game; + + play->fb_fade_type = 8; + play->fb_wipe_type = 3; + Common_Set(wipeType, 3); + mBGMPsComp_make_ps_wipe(0x1168); +} + +static void aAL_title_decide_p_sel_npc() { + int selected; + mActor_name_t npc_name; + int idx; + + while (TRUE) { + selected = (int)(fqrand() * (f32)ANIMAL_NUM_MAX); + if (mNpc_CheckFreeAnimalPersonalID(Save_GetPointer(animals[selected].id)) == FALSE) { + npc_name = Save_Get(animals[selected].id.npc_id); + break; + } + } + + idx = mNpc_SearchAnimalinfo(Save_Get(animals), npc_name, ANIMAL_NUM_MAX); + mNpc_RegistEventNpc(SP_NPC_P_SEL2, npc_name, npc_name, Save_Get(animals[idx].cloth)); +} + +static int aAL_wipe_end_check(GAME* game) { + GAME_PLAY* play = (GAME_PLAY*)game; + int res = FALSE; + fbdemo_wipe* wipe = &play->fbdemo_wipe; + + if ((*wipe->wipe_procs.isfinished_proc)(&wipe->wipe_data)) { + res = TRUE; + } + + return res; +} + +static int aAL_chk_start_key() { + int res = FALSE; + + if (padmgr_isConnectedController(PAD0) && ((gamePT->pads[PAD0].on.button & BUTTON_START) == BUTTON_START || (gamePT->pads[PAD0].on.button & BUTTON_A) == BUTTON_A)) { + res = TRUE; + } + + return res; +} + +static int aAL_chk_start_key2(ANIMAL_LOGO_ACTOR* actor, GAME* game) { + int res = FALSE; + + if (aAL_chk_start_key() == TRUE) { + aAL_setupAction(actor, game, aAL_ACTION_START_KEY_CHK_START); + res = TRUE; + } + + return res; +} + +static void aAL_logo_in(ANIMAL_LOGO_ACTOR* actor, GAME* game) { + int animal_done; + int cros_done; + int sing_done; + + if (aAL_chk_start_key2(actor, game) == FALSE) { + animal_done = cKF_SkeletonInfo_R_play(&actor->animal.skeleton); + cros_done = cKF_SkeletonInfo_R_play(&actor->cros.skeleton); + sing_done = cKF_SkeletonInfo_R_play(&actor->sing.skeleton); + if (animal_done == TRUE && cros_done == TRUE && sing_done == TRUE) { + aAL_setupAction(actor, game, aAL_ACTION_BACK_FADE_IN); + } + } +} + +static void aAL_back_fadein(ANIMAL_LOGO_ACTOR* actor, GAME* game) { + if (aAL_chk_start_key2(actor, game) == FALSE) { + s16 opacity = actor->back_opacity; + opacity += aAL_BACK_FADEIN_RATE; + + if (opacity > aAL_BACK_FADEIN_MAX) { + opacity = aAL_BACK_FADEIN_MAX; + aAL_setupAction(actor, game, aAL_ACTION_START_KEY_CHK_START); + } + + actor->back_opacity = opacity; + } +} + +static void aAL_start_key_chk_start_wait(ANIMAL_LOGO_ACTOR* actor, GAME* game) { + if (padmgr_isConnectedController(PAD0) && actor->title_timer <= 0 && famicom_mount_archive_end_check()) { + aAL_setupAction(actor, game, aAL_ACTION_GAME_START); + } +} + +static void aAL_game_start_wait(ANIMAL_LOGO_ACTOR* actor, GAME* game) { + GAME_PLAY* play = (GAME_PLAY*)game; + f32 start_opacity; + s16 t; + s16 new_opacity_timer; + + new_opacity_timer = actor->start_opacity_timer; + new_opacity_timer += (s16)(32768.0f / (actor->start_opacity_timer > 0 ? 50.0f : 22.0f)); + start_opacity = 127.5f * sin_s(new_opacity_timer) + 127.5f; // 127.5f + 127.5f * [0, 1] = [127.5f, 255.0f] (opacity) + + if (start_opacity > 255.0f) { + start_opacity = 255.0f; + } + else if (start_opacity < 0.0f) { + start_opacity = 0.0f; + } + + actor->press_start_opacity = start_opacity; + actor->start_opacity_timer = new_opacity_timer; + + if (play->fb_fade_type == 10) { + aAL_setupAction(actor, game, aAL_ACTION_6); + } + else if ( + ((gamePT->pads[PAD0].on.button & BUTTON_START) == BUTTON_START || (gamePT->pads[PAD0].on.button & BUTTON_A) == BUTTON_A) && + mLd_CheckStartFlag() == TRUE && + aAL_wipe_end_check(game) == TRUE && + mTD_tdemo_button_ok_check() + ) { + aAL_setupAction(actor, game, aAL_ACTION_FADE_OUT_START); + } +} + +static void aAL_fade_out_start_wait(ANIMAL_LOGO_ACTOR* actor, GAME* game) { + if (actor->title_timer <= 0) { + aAL_title_game_data_init_start_select(actor, game); + aAL_setupAction(actor, game, aAL_ACTION_OUT); + } +} + +extern cKF_Animation_R_c cKF_ba_r_logo_us_animal; +extern cKF_Animation_R_c cKF_ba_r_logo_us_cros; +extern cKF_Animation_R_c cKF_ba_r_logo_us_sing; + +static void aAL_logo_in_init(ANIMAL_LOGO_ACTOR* actor, GAME* game) { + cKF_SkeletonInfo_R_init(&actor->animal.skeleton, actor->animal.skeleton.skeleton, &cKF_ba_r_logo_us_animal, 1.0f, 121.0f, 1.0f, 0.5f, 0.0f, cKF_FRAMECONTROL_STOP, NULL); + cKF_SkeletonInfo_R_init(&actor->cros.skeleton, actor->cros.skeleton.skeleton, &cKF_ba_r_logo_us_cros, 1.0f, 121.0f, 1.0f, 0.5f, 0.0f, cKF_FRAMECONTROL_STOP, NULL); + cKF_SkeletonInfo_R_init(&actor->sing.skeleton, actor->sing.skeleton.skeleton, &cKF_ba_r_logo_us_sing, 1.0f, 121.0f, 1.0f, 0.5f, 0.0f, cKF_FRAMECONTROL_STOP, NULL); + + actor->copyright_opacity = 0; + actor->titledemo_no = mTD_get_titledemo_no(); + + mCD_set_aram_save_data(); + lbRTC_GetTime(Common_GetPointer(time.rtc_time)); + Common_Set(player_no, 0); + Common_Set(player_data_mode, 0); + Common_Set(scene_from_title_demo, -1); +} + +static void aAL_back_fadein_init(ANIMAL_LOGO_ACTOR* actor, GAME* game) { + actor->back_opacity = 0; +} + +static void aAL_start_key_chk_start_wait_init(ANIMAL_LOGO_ACTOR* actor, GAME* game) { + /* move all animations to the final frame (in case animation was skipped) */ + actor->animal.skeleton.frame_control.current_frame = actor->animal.skeleton.frame_control.end_frame; + actor->cros.skeleton.frame_control.current_frame = actor->cros.skeleton.frame_control.end_frame; + actor->sing.skeleton.frame_control.current_frame = actor->sing.skeleton.frame_control.end_frame; + + cKF_SkeletonInfo_R_play(&actor->animal.skeleton); + cKF_SkeletonInfo_R_play(&actor->cros.skeleton); + cKF_SkeletonInfo_R_play(&actor->sing.skeleton); + + actor->copyright_opacity = 255; + actor->back_opacity = aAL_BACK_FADEIN_MAX; + actor->title_timer = aAL_TIMER; +} + +static void aAL_fade_out_start_wait_init(ANIMAL_LOGO_ACTOR* actor, GAME* game) { + sAdo_SysTrgStart(0x44D); + actor->title_timer = aAL_FADEOUT_TIMER; + actor->press_start_opacity = 255.0f; +} + +static void aAL_setupAction(ANIMAL_LOGO_ACTOR* actor, GAME* game, int action) { + static const ANIMAL_LOGO_ACTION_PROC init_proc[aAL_ACTION_NUM] = { + &aAL_logo_in_init, + &aAL_back_fadein_init, + &aAL_start_key_chk_start_wait_init, + (ANIMAL_LOGO_ACTION_PROC)&none_proc1, + &aAL_fade_out_start_wait_init, + (ANIMAL_LOGO_ACTION_PROC)&none_proc1, + (ANIMAL_LOGO_ACTION_PROC)&none_proc1 + }; + + static ANIMAL_LOGO_ACTION_PROC process[aAL_ACTION_NUM] = { + &aAL_logo_in, + &aAL_back_fadein, + &aAL_start_key_chk_start_wait, + &aAL_game_start_wait, + &aAL_fade_out_start_wait, + (ANIMAL_LOGO_ACTION_PROC)&none_proc1, + (ANIMAL_LOGO_ACTION_PROC)&none_proc1 + }; + + (*init_proc[action])(actor, game); + actor->action = action; + actor->action_proc = process[action]; +} + +static void aAL_actor_move(ACTOR* actor, GAME* game) { + ANIMAL_LOGO_ACTOR* logo_actor = (ANIMAL_LOGO_ACTOR*)actor; + + lbRTC_Sampling(); + if (logo_actor->title_timer > 0) { + logo_actor->title_timer--; + } + + (*logo_actor->action_proc)(logo_actor, game); +} + +static void aAL_copyright_draw(ANIMAL_LOGO_ACTOR* actor, GRAPH* graph) { + static const u32 draw_pos_x[3] = { 61, 125, 189 }; + static const u32 draw_pos_y[3] = { 198, 198, 198 }; + + Gfx* gfx; + + actor->copyright_opacity += aAL_COPYRIGHT_ALPHA_RATE; + if (actor->copyright_opacity >= 255) { + actor->copyright_opacity = 255; + } + + OPEN_DISP(graph); + + gfx = NOW_FONT_DISP; + gDPSetPrimColor(gfx++, 0, 255, 40, 40, 45, actor->copyright_opacity); + gDPSetEnvColor(gfx++, 210, 210, 215, 0); + gDPSetOtherMode(gfx++, G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, G_AC_THRESHOLD | G_ZS_PRIM | G_RM_CLD_SURF | G_RM_CLD_SURF2); + gSPLoadGeometryMode(gfx++, 0); + gDPSetCombineMode(gfx++, G_CC_TITLE, G_CC_TITLE); + + gDPLoadTextureTile( + gfx++, + log_win_nintendo1_tex, + G_IM_FMT_IA, G_IM_SIZ_8b, + TITLE_WIDTH, TITLE_HEIGHT, + 0, 0, TITLE_WIDTH - 1, TITLE_HEIGHT - 1, + 0, + G_TX_WRAP | G_TX_NOMIRROR, G_TX_WRAP | G_TX_NOMIRROR, + G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD + ); + gfx = gfx_gSPTextureRectangle1( + gfx, + draw_pos_x[0] << 2, draw_pos_y[0] << 2, + (TITLE_WIDTH + draw_pos_x[0]) << 2, (TITLE_HEIGHT + draw_pos_y[0]) << 2, + 0, + 0 << 5, 0 << 5, + 1 << 10, 1 << 10 + ); + + gDPLoadTextureTile( + gfx++, + log_win_nintendo2_tex, + G_IM_FMT_IA, G_IM_SIZ_8b, + TITLE_WIDTH, TITLE_HEIGHT, + 0, 0, TITLE_WIDTH - 1, TITLE_HEIGHT - 1, + 0, + G_TX_WRAP | G_TX_NOMIRROR, G_TX_WRAP | G_TX_NOMIRROR, + G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD + ); + gfx = gfx_gSPTextureRectangle1( + gfx, + draw_pos_x[1] << 2, draw_pos_y[1] << 2, + (TITLE_WIDTH + draw_pos_x[1]) << 2, (TITLE_HEIGHT + draw_pos_y[1]) << 2, + 0, + 0 << 5, 0 << 5, + 1 << 10, 1 << 10 + ); + + gDPLoadTextureTile( + gfx++, + log_win_nintendo3_tex, + G_IM_FMT_IA, G_IM_SIZ_8b, + TITLE_WIDTH, TITLE_HEIGHT, + 0, 0, TITLE_WIDTH - 1, TITLE_HEIGHT - 1, + 0, + G_TX_WRAP | G_TX_NOMIRROR, G_TX_WRAP | G_TX_NOMIRROR, + G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD + ); + gfx = gfx_gSPTextureRectangle1( + gfx, + draw_pos_x[2] << 2, draw_pos_y[2] << 2, + (TITLE_WIDTH + draw_pos_x[2]) << 2, (TITLE_HEIGHT + draw_pos_y[2]) << 2, + 0, + 0 << 5, 0 << 5, + 1 << 10, 1 << 10 + ); + + SET_FONT_DISP(gfx); + + CLOSE_DISP(graph); +} + +static void aAL_tm_draw(GRAPH* graph) { + static const Gfx init_disp[] = { + gsSPLoadGeometryMode(G_CULL_BACK), + gsDPSetOtherMode(G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_PERSP | G_CYC_1CYCLE | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PRIM | G_RM_XLU_SURF | G_RM_XLU_SURF2), + gsDPSetCombineMode(G_CC_TM, G_CC_TM), + gsSPEndDisplayList() + }; + + Gfx* gfx; + + Matrix_push(); + Matrix_translate(1530.0f, 690.0f, 0.0f, 1); + Matrix_scale(0.162082675f, 0.162082675f, 0.162082675f, 1); + + OPEN_DISP(graph); + + gfx = NOW_FONT_DISP; + gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, init_disp); + gSPDisplayList(gfx++, logo_us_tm_model); + SET_FONT_DISP(gfx); + + CLOSE_DISP(graph); + + Matrix_pull(); +} + +static void aAL_back_draw(GRAPH* graph, ANIMAL_LOGO_ACTOR* actor) { + static const Gfx init_disp[] = { + gsSPTexture(0, 0, 0, 0, G_ON), + gsSPLoadGeometryMode(G_CULL_BACK), + gsDPSetOtherMode(G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_PERSP | G_CYC_1CYCLE | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PRIM | G_RM_XLU_SURF | G_RM_XLU_SURF2), + gsDPSetCombineMode(G_CC_BACK, G_CC_BACK), + gsSPEndDisplayList() + }; + + Gfx* gfx; + + Matrix_push(); + Matrix_translate(0.0f, 730.0f, 0.0f, 1); + Matrix_scale(0.135f, 0.135f, 0.135f, 1); + + OPEN_DISP(graph); + + gfx = NOW_FONT_DISP; + gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(gfx++, 0, 255, 80, 60, 0, actor->back_opacity); + gSPDisplayList(gfx++, init_disp); + gSPDisplayList(gfx++, logo_us_backA_model); + gSPDisplayList(gfx++, logo_us_backB_model); + gSPDisplayList(gfx++, logo_us_backC_model); + gSPDisplayList(gfx++, logo_us_backD_model); + SET_FONT_DISP(gfx); + + CLOSE_DISP(graph); + + Matrix_pull(); +} + +static void aAL_press_start_draw(ANIMAL_LOGO_ACTOR* actor, GRAPH* graph) { + static const u32 draw_pos_x[2] = { 96, 160 }; + static const u32 draw_pos_y[2] = { 159, 159 }; + + static const u32 ps_prim_r[5] = { 70, 60, 60, 40, 40 }; + static const u32 ps_prim_g[5] = { 40, 50, 40, 50, 50 }; + static const u32 ps_prim_b[5] = { 40, 30, 60, 70, 60 }; + + static const u32 ps_env_r[5] = { 255, 255, 255, 120, 165 }; + static const u32 ps_env_g[5] = { 90, 135, 100, 205, 245 }; + static const u32 ps_env_b[5] = { 30, 0, 255, 245, 0 }; + + Gfx* gfx; + int titledemo_no; + f32 alpha; + titledemo_no = actor->titledemo_no; + alpha = actor->press_start_opacity; + + OPEN_DISP(graph); + + gfx = NOW_FONT_DISP; + gDPSetPrimColor(gfx++, 0, 255, ps_prim_r[titledemo_no], ps_prim_g[titledemo_no], ps_prim_b[titledemo_no], (u32)alpha); + gDPSetEnvColor(gfx++, ps_env_r[titledemo_no], ps_env_g[titledemo_no], ps_env_b[titledemo_no], 0); + gDPSetOtherMode(gfx++, G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, G_AC_THRESHOLD | G_ZS_PRIM | G_RM_XLU_SURF | G_RM_XLU_SURF2); + gSPLoadGeometryMode(gfx++, 0); + gDPSetCombineMode(gfx++, G_CC_PRESS_START, G_CC_PRESS_START); + + gDPLoadTextureTile( + gfx++, + log_win_logo3_tex, + G_IM_FMT_IA, G_IM_SIZ_8b, + TITLE_WIDTH, TITLE_HEIGHT, + 0, 0, TITLE_WIDTH - 1, TITLE_HEIGHT - 1, + 0, + G_TX_WRAP | G_TX_NOMIRROR, G_TX_WRAP | G_TX_NOMIRROR, + G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD + ); + + gfx = gfx_gSPTextureRectangle1( + gfx, + draw_pos_x[0] << 2, draw_pos_y[0] << 2, + (TITLE_WIDTH + draw_pos_x[0]) << 2, (TITLE_HEIGHT + draw_pos_y[0]) << 2, + 0, + 0 << 5, 0 << 5, + 1 << 10, 1 << 10 + ); + + gDPLoadTextureTile( + gfx++, + log_win_logo4_tex, + G_IM_FMT_IA, G_IM_SIZ_8b, + TITLE_WIDTH, TITLE_HEIGHT, + 0, 0, TITLE_WIDTH - 1, TITLE_HEIGHT - 1, + 0, + G_TX_WRAP | G_TX_NOMIRROR, G_TX_WRAP | G_TX_NOMIRROR, + G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD + ); + + gfx = gfx_gSPTextureRectangle1( + gfx, + draw_pos_x[1] << 2, draw_pos_y[1] << 2, + (TITLE_WIDTH + draw_pos_x[1]) << 2, (TITLE_HEIGHT + draw_pos_y[1]) << 2, + 0, + 0 << 5, 0 << 5, + 1 << 10, 1 << 10 + ); + + SET_FONT_DISP(gfx); + + CLOSE_DISP(graph); +} + +static void aAL_skl_draw(GAME* game, cKF_SkeletonInfo_R_c* skl_keyframe) { + Mtx* m; + + OPEN_DISP(game->graph); + + m = GRAPH_ALLOC_TYPE(game->graph, Mtx, skl_keyframe->skeleton->num_shown_joints); + if (m != NULL) { + cKF_Si3_draw_R_SV(game, skl_keyframe, m, NULL, NULL, NULL); + } + + CLOSE_DISP(game->graph); +} + +static void aAL_title_draw(GAME* game, ANIMAL_LOGO_ACTOR* actor) { + static const Gfx init_disp[] = { + gsDPSetOtherMode(G_AD_NOTPATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_RGBA16 | G_TL_TILE | G_TD_CLAMP | G_TP_PERSP | G_CYC_1CYCLE | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PRIM | G_RM_XLU_SURF | G_RM_XLU_SURF2), + gsDPSetCombineMode(G_CC_DECALRGBA, G_CC_DECALRGBA), + gsSPLoadGeometryMode(G_CULL_BACK), + gsSPTexture(0, 0, 0, 0, G_ON), + gsSPEndDisplayList() + }; + + Gfx* poly_save; + GRAPH* graph = game->graph; + + Matrix_push(); + Matrix_translate(0.0f, 730.0f, 0.0f, 1); + Matrix_scale(0.135f, 0.135f, 0.135f, 1); + + OPEN_DISP(graph); + + // we need to save the opaque polygon gfx buffer and swap with font because cKF utilizes opaque polygon gfx, + // but we want this on the font gfx buffer + poly_save = NOW_POLY_OPA_DISP; + SET_POLY_OPA_DISP(NOW_FONT_DISP); + gSPMatrix(NOW_POLY_OPA_DISP++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(NOW_POLY_OPA_DISP++, init_disp); + + aAL_skl_draw(game, &actor->animal.skeleton); + aAL_skl_draw(game, &actor->cros.skeleton); + aAL_skl_draw(game, &actor->sing.skeleton); + + SET_FONT_DISP(NOW_POLY_OPA_DISP); + SET_POLY_OPA_DISP(poly_save); + + CLOSE_DISP(graph); + + Matrix_pull(); +} + +static void aAL_actor_draw(ACTOR* actor, GAME* game) { + ANIMAL_LOGO_ACTOR* logo_actor = (ANIMAL_LOGO_ACTOR*)actor; + GRAPH* graph = game->graph; + + mFont_SetMatrix(graph, mFont_MODE_FONT); + + if (logo_actor->action >= aAL_ACTION_BACK_FADE_IN) { + aAL_back_draw(graph, logo_actor); + } + + aAL_title_draw(game, logo_actor); + + if (logo_actor->action >= aAL_ACTION_START_KEY_CHK_START) { + aAL_copyright_draw(logo_actor, graph); + aAL_tm_draw(graph); + } + + mFont_SetMode(graph, mFont_MODE_FONT); + if (padmgr_isConnectedController(PAD0)) { + switch (logo_actor->action) { + case aAL_ACTION_GAME_START: + case aAL_ACTION_FADE_OUT_START: + case aAL_ACTION_OUT: + aAL_press_start_draw(logo_actor, graph); + break; + } + } + + mFont_UnSetMatrix(graph, mFont_MODE_FONT); + game_debug_draw_last(game, graph); + game_draw_last(graph); +} diff --git a/rel/ac_animal_logo_misc.c b/rel/ac_animal_logo_misc.c new file mode 100644 index 00000000..b41cf77e --- /dev/null +++ b/rel/ac_animal_logo_misc.c @@ -0,0 +1,120 @@ +/* This file is evident by the split TUs in symbol map. Unsure of proper filename. */ + +#include "ac_animal_logo.h" + +#include "m_common_data.h" +#include "m_npc.h" +#include "m_name_table.h" +#include "m_play.h" +#include "m_time.h" +#include "m_titledemo.h" +#include "m_event.h" + +extern void flash_rom_and_player_info_clear() { + Save* save = Common_GetPointer(save); + Private_c* priv_p; + int i; + + bzero(save, sizeof(Save)); + mFRm_ClearSaveCheckData(Save_GetPointer(save_check)); + + priv_p = Save_GetPointer(private[0]); + for (i = 0; i < PLAYER_NUM; i++) { + mPr_ClearPrivateInfo(priv_p); + priv_p++; + } + + Save_Set(land_info.exists, TRUE); +} + +extern int decide_next_scene_no() { + int is_first_game; + int bad_save; + int next_scene_no; + + is_first_game = mFRm_CheckSaveData() == FALSE; + + // this is weird, can't get it as a ternary or a switch + switch ((int)Common_Get(save_error_type)) { + case mFRm_ERROR_MEMCARD_TRAVELDATA_CONFLICT: + case mFRm_ERROR_DATA_CORRUPTED: + case mFRm_ERROR_MEMCARD_NO_FILES: + case mFRm_ERROR_MEMCARD_DAMAGED: + case mFRm_ERROR_MEMCARD_FORMAT: + case mFRm_ERROR_MEMCARD_INVALID: + case mFRm_ERROR_MEMCARD_NO_SPACE: + case mFRm_ERROR_NOT_MEMCARD: + case mFRm_ERROR_NO_MEMCARD: + { + bad_save = TRUE; + break; + } + default: + { + bad_save = FALSE; + break; + } + } + + if (lbRTC_IsAbnormal()) { + const lbRTC_time_c* src; + + Common_Set(time.rtc_crashed, TRUE); + Common_Set(time.add_sec, 1); + + if (is_first_game == TRUE || bad_save == TRUE) { + src = &mTM_rtcTime_default_code; + } + else { + src = Save_GetPointer(save_check.time); + } + + lbRTC_TimeCopy(Common_GetPointer(newly_set_time), src); + } + + if (bad_save == TRUE || Common_Get(time.rtc_crashed) == TRUE) { + if (bad_save == TRUE) { + flash_rom_and_player_info_clear(); + } + + Common_Set(house_owner_name, RSV_NO); + Common_Set(last_field_id, -1); + next_scene_no = SCENE_PLAYERSELECT_3; + } + else if (is_first_game == TRUE) { + flash_rom_and_player_info_clear(); + Common_Set(house_owner_name, RSV_NO); + Common_Set(last_field_id, -1); + next_scene_no = SCENE_PLAYERSELECT; + } + else { + next_scene_no = SCENE_PLAYERSELECT_2; + } + + return next_scene_no; +} + +extern void title_action_data_init_start_select(GAME_PLAY* play) { + mCD_LoadLand(); + mCPk_InitPak(0); + + Common_Set(now_private, Save_GetPointer(private[0])); + Common_Set(player_no, 0); + + mTD_rtc_reserve(); + mTM_clear_renew_is(); + mNpc_ClearAnimalInfo(mNpc_GetInAnimalP()); + play->next_scene_no = decide_next_scene_no(); + + { + int rtc_enabled = Common_Get(time.rtc_enabled); + Common_Set(time.rtc_enabled, TRUE); + mTM_rtcTime_limit_check(); + Common_Set(time.rtc_enabled, rtc_enabled); + } + + mEv_ClearEventInfo(); + Common_Set(scene_from_title_demo, -1); + Common_Set(door_data.next_scene_id, 0); + Common_Set(submenu_disabled, TRUE); +} diff --git a/rel/m_select.c b/rel/m_select.c index 2076db24..04dfaf89 100644 --- a/rel/m_select.c +++ b/rel/m_select.c @@ -332,7 +332,7 @@ static void select_pass(GAME_SELECT* select) { (*nf_p->next_play_proc)((GAME*)select, nf_p->scene_no); } - Common_Set(scene_from_title_demo, SCENE_INVALID); + Common_Set(scene_from_title_demo, -1); } static int select_start_proc(GAME_SELECT* select) {