From 82b1436a03c04a26c749325cf8e52f2cdd23a669 Mon Sep 17 00:00:00 2001 From: Prakxo Date: Sun, 2 Jul 2023 15:58:52 +0200 Subject: [PATCH] link train related actors --- config/rel_slices.yml | 12 + include/ac_train0.h | 26 ++ include/ac_train1.h | 20 ++ include/ac_train_window.h | 28 ++ include/evw_anime.h | 23 ++ include/m_actor.h | 1 + include/m_clip.h | 5 +- include/m_kankyo.h | 6 + include/m_lights.h | 9 + include/m_name_table.h | 1 + include/m_play.h | 5 +- include/m_player.h | 6 +- include/sys_math3d.h | 1 + rel/ac_train0.c | 306 +++++++++++++++++++ rel/ac_train1.c | 240 +++++++++++++++ rel/ac_train_window.c | 603 ++++++++++++++++++++++++++++++++++++++ tools/ppcdis | 2 +- 17 files changed, 1289 insertions(+), 5 deletions(-) create mode 100644 include/evw_anime.h create mode 100644 rel/ac_train0.c create mode 100644 rel/ac_train1.c create mode 100644 rel/ac_train_window.c diff --git a/config/rel_slices.yml b/config/rel_slices.yml index e5e72c13..fc74f351 100644 --- a/config/rel_slices.yml +++ b/config/rel_slices.yml @@ -192,6 +192,10 @@ ac_train_door.c: .text: [0x804AC2D8, 0x804AC510] .rodata: [0x80645F98, 0x80645FA8] .data: [0x8068F5C0, 0x8068F600] +ac_train_window.c: + .text: [0x804AC510, 0x804AD428] + .rodata: [0x80645FA8, 0x80645FF8] + .data: [0x8068F600, 0x8068F830] m_huusui_room_ovl.c: .text: [0x804D1BBC, 0x804D2164] .rodata: [0x80646558, 0x806465C8] @@ -205,6 +209,14 @@ ac_structure.c: .rodata: [0x8064AC30, 0x8064AC38] .data: [0x806C6C00, 0x806C6ED0] .bss: [0x813280F0, 0x8133DEB0] +ac_train0.c: + .text: [0x805BFC28, 0x805C0614] + .rodata: [0x8064AD28, 0x8064AD80] + .data: [0x806C72D0, 0x806C7300] +ac_train1.c: + .text: [0x805C0614, 0x805C0CC8] + .rodata: [0x8064AD80, 0x8064ADB0] + .data: [0x806C7300, 0x806C7388] m_select.c: .text: [0x80627F88, 0x80629CA8] .rodata: [0x8064D1B0, 0x8064D1B8] diff --git a/include/ac_train0.h b/include/ac_train0.h index 193773a4..eec0107f 100644 --- a/include/ac_train0.h +++ b/include/ac_train0.h @@ -3,11 +3,37 @@ #include "types.h" #include "m_actor.h" +#include "c_keyframe.h" +#include "m_lib.h" #ifdef __cplusplus extern "C" { #endif +typedef int (*aTR0_SETUP_ACTOR_PROC)(GAME_PLAY*, mActor_name_t,int,int,int,int,int,int,int); + +typedef struct ac_train0_clip_s{ + aTR0_SETUP_ACTOR_PROC setup_actor_proc; +}aTR0_Clip_c; + +typedef struct train0_s{ + ACTOR actor_class; + int steam_available; + cKF_SkeletonInfo_R_c keyframe; + int steam_timer; + s_xyz work[15]; + s_xyz target[15]; + u8 pad4[0x2b4 - 0x2A0]; + int tr_action; + u8 pad5[0x2BC - 0x2B8]; + int effect_num; + int unk2c0; + ACTOR* tr_actor_p; + f32 tr1_pos; + f32 tr_speed; + u8 pad6[0x2D8 - 0x2CC]; +}TRAIN0_ACTOR; + extern ACTOR_PROFILE Train0_Profile; #ifdef __cplusplus diff --git a/include/ac_train1.h b/include/ac_train1.h index ce25ee1e..c90c33a4 100644 --- a/include/ac_train1.h +++ b/include/ac_train1.h @@ -3,11 +3,31 @@ #include "types.h" #include "m_actor.h" +#include "c_keyframe.h" +#include "m_lib.h" #ifdef __cplusplus extern "C" { #endif +typedef struct train1_s{ + ACTOR actor_class; + int anim_state; + cKF_SkeletonInfo_R_c keyframe; + int timer; + s_xyz work[15]; + s_xyz morph[15]; + u8 pad4[0x2b4 - 0x2A0]; + int tr_action; + int player_pass_exists; + int player_pass_leaving; //Not sure about this one + int unk2c0; + ACTOR* tr_actor_p; + f32 tr_speed; + f32 tr0_pos; + u8 pad2[0x2D8-0x2CC]; +}TRAIN1_ACTOR; + extern ACTOR_PROFILE Train1_Profile; #ifdef __cplusplus diff --git a/include/ac_train_window.h b/include/ac_train_window.h index c1880764..8fd831d6 100644 --- a/include/ac_train_window.h +++ b/include/ac_train_window.h @@ -8,6 +8,34 @@ extern "C" { #endif +typedef int (*TRAIN_WINDOW_DRAW_TYPE)(ACTOR*, GAME*); + +#define CRV_DEBUG_LOD_VALUE 87 +#define CRV_DEBUG_RED_VALUE 88 +#define CRV_DEBUG_GREEN_VALUE 89 +#define CRV_DEBUG_BLUE_VALUE 90 + + +typedef struct train_window_s{ + ACTOR actor_class; + TRAIN_WINDOW_DRAW_TYPE draw_type; + s16 pallete_id; + int unk17C; + u16* current_pallete; + u32 Single_Scrollx; + u32 Single_Scrolly; + u32 Two_Scrollx1; + u32 Two_Scrolly1; + u32 Two_Scrollx2; + u32 Two_Scrolly2; + int TreeScrollx; + int TreeScrolly; + f32 xlu_alpha; + f32 scroll_speed; + s_xyz pos; + f32 lod_factor; +}TRAIN_WINDOW_ACTOR; + extern ACTOR_PROFILE Train_Window_Profile; #ifdef __cplusplus diff --git a/include/evw_anime.h b/include/evw_anime.h new file mode 100644 index 00000000..c1ba1c46 --- /dev/null +++ b/include/evw_anime.h @@ -0,0 +1,23 @@ +#ifndef EVW_ANIME_H +#define EVW_ANIME_H + +#include "types.h" + +#ifdef __cplusplus +extern "C"{ +#endif + + +typedef struct evw_anime_s{ + s16 unk0; + s16 unk4; + void* data_p; +}EVW_ANIME_DATA; + +void Evw_Anime_Set(GAME*, EVW_ANIME_DATA*); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/include/m_actor.h b/include/m_actor.h index 866c140a..9ab3d4cc 100644 --- a/include/m_actor.h +++ b/include/m_actor.h @@ -27,6 +27,7 @@ typedef void (*mActor_proc)(ACTOR*, GAME*); #define ACTOR_OBJ_BANK_7 7 #define ACTOR_OBJ_BANK_11 11 #define ACTOR_OBJ_BANK_12 12 +#define ACTOR_OBJ_BANK_41 41 enum actor_part { ACTOR_PART_FG, diff --git a/include/m_clip.h b/include/m_clip.h index f9062c73..a34a5234 100644 --- a/include/m_clip.h +++ b/include/m_clip.h @@ -2,6 +2,7 @@ #define M_CLIP_H #include "types.h" +#include "ac_train0.h" #include "ac_gyoei_h.h" #include "ac_insect_h.h" #include "ac_structure.h" @@ -15,7 +16,9 @@ extern "C" { /* sizeof(Clip_c) == 0x104 */ typedef struct clip_s { - /* 0x000 */ void* _000[(0x07C - 0x000) / sizeof(void*)]; + /* 0x000 */ void* _000[(0x040 - 0x000) / sizeof(void*)]; + /* 0x040 */ aTR0_Clip_c* train0_clip; + /* 0x044 */ void* _044[(0x07C - 0x044) / sizeof(void*)]; /* 0x07C */ aINS_Clip_c* insect_clip; /* 0x080 */ void* _080[(0x08C - 0x080) / sizeof(void*)]; /* 0x08C */ aSTR_Clip_c* structure_clip; diff --git a/include/m_kankyo.h b/include/m_kankyo.h index a1856fcb..79ec3ad0 100644 --- a/include/m_kankyo.h +++ b/include/m_kankyo.h @@ -26,6 +26,12 @@ enum weather_intensity { mEnv_WEATHER_INTENSITY_NUM, }; +typedef struct kankyo_s{ + /*0x00 */ u8 pad[0x9A]; + /*0x9A */ u8 ambientColor[3]; + /*0x9E */ u8 pad2[0x32]; +}Kankyo; + extern int mEnv_NowWeather(); #ifdef __cplusplus diff --git a/include/m_lights.h b/include/m_lights.h index 827d13f6..522ae2e0 100644 --- a/include/m_lights.h +++ b/include/m_lights.h @@ -13,6 +13,15 @@ typedef struct lightsn_s { Lights7 lights; } LightsN; + +typedef struct global_light_s { + /* 0x0 */ void* list; + /* 0x4 */ u8 ambientColor[3]; + /* 0x7 */ u8 fogColor[3]; + /* 0xA */ s16 fogNear; + /* 0xC */ s16 fogFar; +} Global_light; + #ifdef __cplusplus } #endif diff --git a/include/m_name_table.h b/include/m_name_table.h index ed1b5f0e..16e203ad 100644 --- a/include/m_name_table.h +++ b/include/m_name_table.h @@ -566,6 +566,7 @@ extern int mNT_check_unknown(mActor_name_t item_no); #define ETC_AIRPLANE ETC_START #define ETC_BOXTRICK (ETC_START + 4) #define ETC_BOXMANAGER (ETC_START + 5) +#define ETC_TRAIN_WINDOW (ETC_START + 17) #define MISC_ACTOR_START 0x9000 #define MISC_ACTOR_SAMPLE MISC_ACTOR_START diff --git a/include/m_play.h b/include/m_play.h index 1807ad2c..ea4d5de3 100644 --- a/include/m_play.h +++ b/include/m_play.h @@ -7,6 +7,8 @@ #include "m_view.h" #include "m_camera2.h" #include "m_submenu.h" +#include "m_kankyo.h" +#include "m_lights.h" #include "m_pause.h" #include "m_field_info.h" #include "m_fbdemo_wipe.h" @@ -29,7 +31,8 @@ struct game_play_s { /* 0x0110 */ Object_Exchange_c object_exchange; /* 0x1A68 */ View view; /* 0x1B88 */ Camera2 camera; - /* 0x1CC0 */ u8 _1CC0[0x1DA0 - 0x1CC0]; + /* 0x1CC0 */ Kankyo kankyo; + /* 0x1D90 */ Global_light global_light; /* 0x1DA0 */ pause_t pause; /* 0x1DA8 */ Actor_info actor_info; /* 0x1DEC */ Submenu submenu; diff --git a/include/m_player.h b/include/m_player.h index 0c01210f..01d6e0aa 100644 --- a/include/m_player.h +++ b/include/m_player.h @@ -15,8 +15,10 @@ typedef struct player_actor_s PLAYER_ACTOR; struct player_actor_s { /* 0x0000 */ ACTOR actor_class; /* 0x0174 */ u8 tmp0174[0x1300 - 0x0174]; - /* 0x1300 */ void* (*get_door_label_proc)(GAME*); - /* 0x1304 */ u8 tmp1304[0x1318 - 0x1304]; + /* 0x1300 */ void* (*get_door_label_proc)(GAME*); + /* 0x1304 */ u8 tmp1304[0x1310- 0x1304]; + /* 0x1310 */ void (*update_Rot_Pos_actor_proc)(GAME*, xyz_t*, s_xyz*, int); + /* 0x1314 */ u32 pad; /* 0x1318 */ int (*Get_WadeEndPos_proc)(GAME*, xyz_t*); /* 0x131C */ u8 tmp131C[0x13A8 - 0x131C]; /* TODO: finish */ diff --git a/include/sys_math3d.h b/include/sys_math3d.h index e4ca3501..34e69e78 100644 --- a/include/sys_math3d.h +++ b/include/sys_math3d.h @@ -21,6 +21,7 @@ extern void sMath_RotateY(xyz_t* pos, f32 rad); extern void sMath_RotateZ(xyz_t* pos, f32 rad); extern xyz_t ZeroVec; +extern s_xyz ZeroSVec; #ifdef __cplusplus } diff --git a/rel/ac_train0.c b/rel/ac_train0.c new file mode 100644 index 00000000..5810785c --- /dev/null +++ b/rel/ac_train0.c @@ -0,0 +1,306 @@ +#include "ac_train0.h" + +#include "m_name_table.h" +#include "m_common_data.h" +#include "m_field_info.h" +#include "m_event.h" +#include "sys_matrix.h" +#include "m_play.h" + +static void aTR0_actor_ct(ACTOR* actor, GAME* game); +static void aTR0_actor_dt(ACTOR* actor, GAME* game); +static void aTR0_actor_move(ACTOR* actor, GAME* game); +static void aTR0_actor_draw(ACTOR* actor, GAME* game); + +ACTOR_PROFILE Train0_Profile = { + mAc_PROFILE_TRAIN0, + ACTOR_PART_ITEM, + ACTOR_STATE_CAN_MOVE_IN_DEMO_SCENES | 1 << 11 | ACTOR_STATE_NO_MOVE_WHILE_CULLED, //figure out flag 0x800 + TRAIN0, + ACTOR_OBJ_BANK_3, + sizeof(TRAIN0_ACTOR), + &aTR0_actor_ct, + &aTR0_actor_dt, + &aTR0_actor_move, + &aTR0_actor_draw, + NULL +}; + +extern cKF_Skeleton_R_c cKF_bs_r_obj_train1_1; +extern cKF_Animation_R_c cKF_ba_r_obj_train1_1; + +extern Gfx obj_train1_2_model[]; + +static void aTR0_actor_ct(ACTOR* actor, GAME* GAME){ + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + + cKF_SkeletonInfo_R_ct(&train0->keyframe, &cKF_bs_r_obj_train1_1,NULL, train0->work, train0->target); + cKF_SkeletonInfo_R_init(&train0->keyframe, train0->keyframe.skeleton, &cKF_ba_r_obj_train1_1, + 1.0f, 25.0f, 1.0f, 0.5f, 0.0f, 1, NULL); + cKF_SkeletonInfo_R_play(&train0->keyframe); + train0->actor_class.cull_width = 600.0f; + train0->actor_class.world_rotation.y = 16384; + train0->tr_action = 5; +} + +static void aTR0_actor_dt(ACTOR* actor, GAME* game){ + + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + + xyz_t tr_home_pos; + + tr_home_pos = train0->actor_class.home_position; + + mFI_SetFG_common(0, tr_home_pos, 0); + + if(train0->tr_actor_p != NULL){ + Actor_delete(train0->tr_actor_p); + train0->tr_actor_p = NULL; + } + cKF_SkeletonInfo_R_dt(&train0->keyframe); + Common_Set(train_exists_flag, 0); +} + +static void aTR0_ctrl_engineer(ACTOR* actor, GAME* game){ + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + GAME_PLAY* play = (GAME_PLAY* )game; + + + ACTOR* ac_p; + + ac_p = train0->tr_actor_p; + + if(ac_p == NULL){ + + if((*Common_Get(clip.train0_clip)->setup_actor_proc)(play, SP_NPC_ENGINEER, -1,-1,-1,-1,-1,0,0) == 1){ + train0->tr_actor_p = Actor_info_fgName_search(&play->actor_info, SP_NPC_ENGINEER, ACTOR_PART_4); + } + } + else{ + ac_p->world_position.x = -40.0f + train0->actor_class.world_position.x; + ac_p->world_position.y = 47.0f + train0->actor_class.world_position.y; + ac_p->world_position.z = 20.0f + train0->actor_class.world_position.z; + } +} + +static void aTR0_set_effect(ACTOR* actor, GAME* game){ + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + + int calc; + xyz_t pos; + xyz_t clip_pos; + if(train0->effect_num <= 0){ + if(train0->actor_class.speed >= 1.0f){ + calc = (12.0f/train0->actor_class.speed); + train0->effect_num = calc; + } + else{ + train0->effect_num = 12; + } + xyz_t_move(&pos, &train0->actor_class.world_position); + pos.x += 36.0f; + pos.y += 110.0f; + + if(mEv_CheckTitleDemo() == 0){ + clip_pos = pos; + (*Common_Get(clip.effect_clip)->effect_make_proc)(35, clip_pos, 1,0, game, train0->actor_class.npc_id, 0,0); + } + } + else{ + train0->effect_num--; + } +} + +static void aTR0_steam_work_sub(ACTOR* actor, GAME* game, int x_idx){ + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + xyz_t pos; + xyz_t clip_pos; + int unk2c0; + static f32 setX[] = {15.0f, 22.0f}; + static s16 angl[] = {0xd000, 0x0400}; + + pos.x = train0->actor_class.world_position.x + setX[x_idx]; + pos.y = train0->actor_class.world_position.y + 21.0f; + pos.z = train0->actor_class.world_position.z + 42.0f; + unk2c0 = train0->unk2c0; + if(mEv_CheckTitleDemo() == 0){ + clip_pos = pos; + (*Common_Get(clip.effect_clip)->effect_make_proc)(63, clip_pos, 1,angl[x_idx], game, train0->actor_class.npc_id, 0,0); + } + unk2c0++; + train0->unk2c0 = unk2c0 % 4; +} + +static void aTR0_steam_work(ACTOR* actor, GAME* game){ + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + + if(train0->steam_available == 1){ + if((train0->steam_timer >= 2) && (train0->steam_timer <= 5)){ + aTR0_steam_work_sub(actor,game,0); + } + if((train0->steam_timer >= 13) && (train0->steam_timer <= 16)){ + aTR0_steam_work_sub(actor,game,1); + } + } +} + +static f32 calc_speed1(ACTOR* actor){ + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + + if(fabsf(train0->tr_speed) < 0.008f){ + return 0.8f + train0->actor_class.speed; + } + + if(train0->tr_speed < train0->actor_class.speed){ + return train0->actor_class.speed + (0.5f * - (train0->tr_speed - train0->actor_class.speed)); + } + + return train0->actor_class.speed; +} + +static f32 calc_speed2(ACTOR* actor){ + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + int should_stop = fabsf(train0->actor_class.speed) < 0.008f; + + return should_stop == FALSE ? train0->actor_class.speed : -0.23f; +} + +static void aTR0_ctrl_back_car(ACTOR* actor){ + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + + f32 tr_back_calc = train0->tr1_pos; + f32 base_x_pos = -125.0f + train0->actor_class.world_position.x; + tr_back_calc += 0.5f * train0->tr_speed; + + if((tr_back_calc - base_x_pos) > 2.0f){ + train0->tr_speed = calc_speed2(actor); + train0->tr1_pos = 2.0f + base_x_pos; + } + else if((tr_back_calc - base_x_pos) <= 0.0f){ + train0->tr_speed = calc_speed1(actor); + train0->tr1_pos = base_x_pos; + } + else{ + chase_f(&train0->tr_speed, 0.0f, 0.0025f); + train0->tr1_pos = tr_back_calc; + } +} + +static void aTR0_animation(ACTOR* actor){ + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + + int av = 0; + int cur_frame = train0->keyframe.frame_control.current_frame; + cKF_SkeletonInfo_R_play(&train0->keyframe); + + if( cur_frame!= train0->steam_timer){ + train0->steam_timer = cur_frame; + av = 1; + } + train0->steam_available = av; +} + +static void aTR0_move(ACTOR* actor){ + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + xyz_t pos; + + if(train0->tr_action != Common_Get(train_action)){ + train0->tr_action = Common_Get(train_action); + } + pos = Common_Get(train_position); + train0->actor_class.world_position.x = pos.x; + train0->actor_class.world_position.z = pos.z; + train0->actor_class.speed = Common_Get(train_speed); +} + +static void aTR0_delcheck(ACTOR* actor,GAME* game){ + GAME_PLAY* play = (GAME_PLAY* )game; + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + + int x; + int z; + int abs_x; + xyz_t pos; + + pos = train0->actor_class.world_position; + + mFI_Wpos2BlockNum(&x,&z,pos); + x -= play->block_table.block_x; + abs_x = x >= 0 ? x: -x; + + if((abs_x >= 2) || (z != play->block_table.block_z) || (train0->tr_action == 0)){ + if((int)train0->tr_actor_p != 0){ + Actor_delete(train0->tr_actor_p); + } + Actor_delete(actor->child_actor); + Actor_delete(actor); + } +} + +static void aTR0_actor_move(ACTOR* actor, GAME* game){ + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + GAME_PLAY* play = (GAME_PLAY* )game; + + f32 speed; + aTR0_animation(actor); + aTR0_move(actor); + + if(!(fabsf(train0->actor_class.speed) < 0.008f)){ + aTR0_set_effect(actor,game); + aTR0_steam_work(actor,game); + } + + if(mEv_CheckTitleDemo() == 1){ + train0->tr1_pos = -125.0f + train0->actor_class.world_position.x; + } + else{ + aTR0_ctrl_back_car(actor); + } + + aTR0_ctrl_engineer(actor,game); + + speed = (train0->actor_class.speed / 40.0f) * 10.0f; + + if(speed >= 0.5f){ + speed = 0.5f; + } + + train0->keyframe.frame_control.speed = speed; + aTR0_delcheck(&train0->actor_class, game); +} + +static void aTR0_actor_draw(ACTOR* actor, GAME* game){ + u16* pal = (*Common_Get(clip).structure_clip->get_pal_segment_proc)(0x39); + GRAPH* graph = game->graph; + cKF_SkeletonInfo_R_c* keyf; + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; + + Mtx* mtx; + Gfx* gfx; + + keyf = &train0->keyframe; + mtx = GRAPH_ALLOC_TYPE(graph, Mtx, keyf->skeleton->num_shown_joints); + + if (mtx != NULL){ + _texture_z_light_fog_prim_npc(graph); + Matrix_push(); + Matrix_translate(train0->tr1_pos, train0->actor_class.world_position.y, + train0->actor_class.world_position.z, 0); + Matrix_scale(train0->actor_class.scale.x, train0->actor_class.scale.y, + train0->actor_class.scale.z, 1); + + OPEN_DISP(graph); + gfx = NOW_POLY_OPA_DISP; + + gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(gfx++, G_MWO_SEGMENT_8, pal); + gDPLoadTLUT_Dolphin(gfx++, 15, 16, 1, pal); + gSPDisplayList(gfx++, obj_train1_2_model); + + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(graph); + + Matrix_pull(); + cKF_Si3_draw_R_SV(game, keyf, mtx, NULL,NULL,train0); + } +} \ No newline at end of file diff --git a/rel/ac_train1.c b/rel/ac_train1.c new file mode 100644 index 00000000..50b8a385 --- /dev/null +++ b/rel/ac_train1.c @@ -0,0 +1,240 @@ +#include "ac_train1.h" +#include "ac_train0.h" + +#include "graph.h" +#include "m_name_table.h" +#include "m_rcp.h" +#include "m_player.h" +#include "m_player_lib.h" +#include "sys_math3d.h" +#include "m_common_data.h" +#include "m_field_info.h" +#include "m_event.h" + + +static void aTR1_actor_ct(ACTOR* actor, GAME* game); +static void aTR1_actor_dt(ACTOR* actor, GAME* game); +static void aTR1_actor_move(ACTOR* actor, GAME* game); +static void aTR1_actor_draw(ACTOR* actor, GAME* game); + +ACTOR_PROFILE Train1_Profile = { + mAc_PROFILE_TRAIN1, + ACTOR_PART_ITEM, + ACTOR_STATE_CAN_MOVE_IN_DEMO_SCENES | 1 << 11 | ACTOR_STATE_NO_MOVE_WHILE_CULLED, //figure out flag 0x800 + TRAIN1, + ACTOR_OBJ_BANK_3, + sizeof(TRAIN1_ACTOR), + &aTR1_actor_ct, + &aTR1_actor_dt, + &aTR1_actor_move, + &aTR1_actor_draw, + NULL +}; + +extern cKF_Skeleton_R_c cKF_bs_r_obj_train1_3; +extern cKF_Animation_R_c cKF_ba_r_obj_train1_3_open; +extern cKF_Animation_R_c cKF_ba_r_obj_train1_3_close; + + +static void aTR1_setupAction(ACTOR*, int); + +static void aTR1_actor_ct(ACTOR* actor, GAME* game){ + TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor; + + cKF_SkeletonInfo_R_ct(&train1->keyframe, &cKF_bs_r_obj_train1_3, NULL, train1->work, train1->morph); + aTR1_setupAction((ACTOR*)train1, 5); + train1->anim_state = cKF_SkeletonInfo_R_play(&train1->keyframe); + actor->world_rotation.y = 0x4000; + train1->tr_speed = 1.0f; +} + + +static void aTR1_actor_dt(ACTOR* actor, GAME* game){ + TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor; + + xyz_t tr_home_pos; + + tr_home_pos = train1->actor_class.home_position; + + mFI_SetFG_common(EMPTY_NO, tr_home_pos, FALSE); + cKF_SkeletonInfo_R_dt(&train1->keyframe); +} + +static void aTR1_OngenTrgStart(ACTOR* actor, u16 id){ + TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor; + + sAdo_OngenTrgStart(id, &train1->actor_class.world_position); +} + +static f32 calc_speed1(ACTOR* actor0, ACTOR* actor1) { + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor0; + TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor1; + + if (fabsf(actor1->speed) < 0.008f) { + return 0.8f + train0->tr_speed; + } + + if (actor1->speed < train0->tr_speed){ + return train0->tr_speed + (0.5f * - (actor1->speed - train0->tr_speed)); + } + + return train0->tr_speed; +} + +static f32 calc_speed2(ACTOR* actor){ + TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor; + int should_stop = fabsf(train1->tr0_pos) < 0.008f; + + return should_stop == FALSE ? train1->tr0_pos : -0.23f; +} + +static void aTR1_position_move(ACTOR* actor){ + TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor; + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor->parent_actor; + + f32 diff; + f32 tr_back_calc; + f32 base_x_pos; + + tr_back_calc = train1->actor_class.world_position.x; + base_x_pos = -125.0f + train0->tr1_pos; + tr_back_calc += 0.5f * train1->actor_class.speed; + + diff = tr_back_calc - base_x_pos; + if((diff) <= 0.0f){ + train1->actor_class.speed = calc_speed1(actor->parent_actor, actor); + train1->actor_class.world_position.x = base_x_pos; + } + else if((diff) > 2.0f){ + train1->actor_class.speed = calc_speed2(actor->parent_actor); + train1->actor_class.world_position.x = 2.0f + base_x_pos; + } + else{ + chase_f(&train1->actor_class.speed, 0.0f, 0.0025f); + train1->actor_class.world_position.x = tr_back_calc; + } +} + +static void aTR1_chg_station_attr(int station){ + static xyz_t doorway_pos = { 2180.0f, 0.0f, 820.0f }; + xyz_t soil_pos; + xyz_t unk20_pos; + + if(mEv_CheckFirstIntro() == 0){ + if(station == 5){ + soil_pos = doorway_pos; + mCoBG_SetAttribute(&soil_pos, 7); + } + else if(station == 6){ + unk20_pos = doorway_pos; + mCoBG_SetAttribute(&unk20_pos, 0x20); + } + } +} + +static void aTR1_passenger_ctrl(ACTOR* actor){ + TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor; + + GAME_PLAY* play = (GAME_PLAY*)gamePT; + xyz_t pos; + s_xyz rot; + + if(train1->player_pass_exists == 1){ + pos.x = train1->actor_class.world_position.x + 60.0f; + pos.y = train1->actor_class.world_position.y + 20.0f; + pos.z = train1->actor_class.world_position.z + 20.0f; + rot.x = ZeroSVec.x; + rot.y = ZeroSVec.y; + rot.z = ZeroSVec.z; + get_player_actor_withoutCheck((GAME_PLAY*)gamePT)->update_Rot_Pos_actor_proc(gamePT, &pos, &rot, 46); + } + else if(train1->player_pass_leaving == 1){ + pos.x = train1->actor_class.world_position.x + 2.0f; + pos.y = train1->actor_class.world_position.y + 16.0f; + pos.z = train1->actor_class.world_position.z + 20.0f; + get_player_actor_withoutCheck((GAME_PLAY*)gamePT)->update_Rot_Pos_actor_proc(gamePT, &pos, NULL, 14); + + } +} + +#pragma pool_data on +static void aTR1_setupAction(ACTOR* actor, int action){ + TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor; + + static cKF_Animation_R_c* anime_table[] = {&cKF_ba_r_obj_train1_3_open, &cKF_ba_r_obj_train1_3_close}; + static f32 anime_end[] = {24.0f, 32.0f}; + static int animeSeqNoTable[] = {0,0,0,0,0,1,1,0,0}; + static f32 anime_spd[] = {0.0f,0.0f,0.0f,0.0f, 0.5f, 0.0f,0.5f,0.0f,0.0f}; + + cKF_Animation_R_c* anime_pt; + f32 speed; + f32 end; + f32 tr_speed; + int seq_no = animeSeqNoTable[action]; + + anime_pt = anime_table[seq_no]; + speed = anime_spd[action]; + end = anime_end[seq_no]; + + tr_speed = 1.0f; + train1->tr_action = action; + + if((train1->tr_action == 6) || (train1->tr_action == 4)){ + if((mEv_CheckTitleDemo() == 0) && (tr_speed != train1->tr_speed)){ + aTR1_OngenTrgStart(actor, 43); + } + else{ + tr_speed = end; + } + } + cKF_SkeletonInfo_R_init(&train1->keyframe, train1->keyframe.skeleton, anime_pt, + 1.0f, end, tr_speed, speed, 0.0f, 0, NULL ); + aTR1_chg_station_attr(action); +} +#pragma pool_data reset + +static void aTR1_actor_move(ACTOR* actor, GAME* game){ + TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor; + TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor->parent_actor; + cKF_SkeletonInfo_R_c* keyframe = &train1->keyframe; + + + train1->anim_state = cKF_SkeletonInfo_R_play(keyframe); + if(mEv_CheckTitleDemo() <= 0){ + aTR1_position_move((ACTOR*)train1); + } + aTR1_passenger_ctrl((ACTOR*)train1); + + if(train0->tr_action != train1->tr_action){ + aTR1_setupAction((ACTOR*)train1, train0->tr_action); + } + + train1->tr_speed = 0.0f; +} + +static void aTR1_actor_draw(ACTOR* actor, GAME* game){ + u16* pal = (*Common_Get(clip).structure_clip->get_pal_segment_proc)(0x3A); + + TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor; + + GRAPH* graph = game->graph; + cKF_SkeletonInfo_R_c* keyf; + Mtx* mtx; + Gfx* gfx; + + keyf = &train1->keyframe; + mtx = GRAPH_ALLOC_TYPE(graph, Mtx, keyf->skeleton->num_shown_joints); + + if(mtx != NULL){ + _texture_z_light_fog_prim_npc(graph); + + OPEN_DISP(graph); + + gfx = NOW_POLY_OPA_DISP; + gSPSegment(gfx++, 0x8, pal); + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(graph); + + cKF_Si3_draw_R_SV(game, keyf, mtx, NULL,NULL,train1); + } +} diff --git a/rel/ac_train_window.c b/rel/ac_train_window.c new file mode 100644 index 00000000..3729abda --- /dev/null +++ b/rel/ac_train_window.c @@ -0,0 +1,603 @@ +#include "ac_train_window.h" +#include "m_common_data.h" +#include "m_debug.h" +#include "m_name_table.h" +#include "evw_anime.h" +#include "m_rcp.h" +#include "m_play.h" +#include "sys_matrix.h" + + +u16 aTrainWindow_tree_pal_table[15][16]= { +{ +0x0724,0xA443, +0xBCA4,0xDD25, +0xF5E7,0xF209, +0xFECD,0x0545, +0x9885,0xA0C5, +0xAD05,0xBD66, +0xCDE8,0xD2FA, +0xE77C,0xF3BE +}, +{ +0x0724,0xA443, +0xBCA4,0xDD25, +0xF5E7,0xF209, +0xFECD,0x0655, +0x98C5,0xA105, +0xB165,0xC1E6, +0xD268,0xD2FA, +0xE77C,0xF3BE +}, +{ +0x0724,0xA443, +0xBCA4,0xDD25, +0xF5E7,0xF209, +0xFECD,0x0464, +0x90C3,0x9504, +0xA184,0xAA05, +0xB287,0xD2FA, +0xE77C,0xF3BE +}, +{ +0x0724,0xA443, +0xBCA4,0xDD25, +0xF5E7,0xF209, +0xFECD,0x0164, +0x80E5,0x8145, +0x89A4,0x9A60, +0xB300,0xD380, +0xEFE8,0x8000 +}, +{ +0x0724,0xA443, +0xBCA4,0xDD25, +0xF5E7,0xF209, +0xFECD,0x0C37, +0xB086,0xC8A7, +0xE0C7,0xF109, +0xF98C,0xFE10, +0xFF18,0x8000 +}, +{ +0x0724,0xA443, +0xBCA4,0xDD25, +0xF5E7,0xF209, +0xFECD,0x0066, +0x80C9,0x8127, +0x8186,0x8202, +0x82C1,0x9380, +0xCBE8,0x8000 +}, +{ +0x0724,0xA443, +0xBCA4,0xDD25, +0xF5E7,0xF209, +0xFECD,0x0058, +0x80C9,0x80E8, +0x8148,0x81C8, +0x8268,0x9326, +0xC3EB,0x8000 +}, +{ +0x0724,0xA443, +0xBCA4,0xDD25, +0xF5E7,0xF209, +0xFECD,0x0353, +0x8CC2,0x9102, +0x9963,0xA5C4, +0xB242,0xC6E4, +0xDB88,0x8000 +}, +{ +0x0724,0xA443, +0xBCA4,0xDD25, +0xF5E7,0xF209, +0xFECD,0x0564, +0x90C5,0x9924, +0xA984,0xBA03, +0xD2A3,0xE304, +0xEF6A,0x8000 +}, +{ +0x0724,0xA443, +0xBCA4,0xDD25, +0xF5E7,0xF209, +0xFECD,0x0842, +0xA463,0xB4A2, +0xC502,0xD961, +0xE9E1,0xF682, +0xFF26,0x8000 +}, +{ +0x0724,0xA443, +0xBCA4,0xDD25, +0xF5E7,0xF209, +0xFECD,0x0814, +0xB024,0xC044, +0xCC85,0xE0C6, +0xF128,0xFE0B, +0xFEEB,0x8000 +}, +{ +0x0724,0xA443, +0xBCA4,0xDD25, +0xF5E7,0xF209, +0xFECD,0x0734, +0xA484,0xAC83, +0xBCC4,0xD503, +0xE985,0xF629, +0xFF0E,0x8000 +}, +{ +0x0724,0xA443, +0xBCA4,0xDD25, +0xF5E7,0xF209, +0xFECD,0x0635, +0xA085,0xA8C5, +0xB505,0xC566, +0xD5E8,0xEE8A, +0xFF2C,0x8000 +}, +{ +0x0724,0xA443, +0xBCA4,0xDD25, +0xF5E7,0xF209, +0xFECD,0x0545, +0x9885,0xA0C5, +0xAD05,0xBD66, +0xCDE8,0xD2FA, +0xE77C,0xF3BE +}, +{ +0x0724,0xA443, +0xBCA4,0xDD25, +0xF5E7,0xF209, +0xFECD,0x0545, +0x9885,0xA0C5, +0xAD05,0xBD66, +0xCDE8,0xD2FA, +0xE77C,0xF3BE +} +}; + +u8 aTrainWindow_out_cloud[4] = { + 0,254, + 64,64 +}; + +EVW_ANIME_DATA aTrainWindow_evw_anime_data = { + -512, 0, &aTrainWindow_out_cloud +}; + +static void Train_Window_Actor_ct(ACTOR*, GAME*); +static void Train_Window_Actor_dt(ACTOR*, GAME*); +static void Train_Window_Actor_move(ACTOR*, GAME*); +static void Train_Window_Actor_draw(ACTOR*, GAME*); + + +ACTOR_PROFILE Train_Window_Profile = { + mAc_PROFILE_TRAIN_WINDOW, + ACTOR_PART_ITEM, + ACTOR_STATE_NO_DRAW_WHILE_CULLED | ACTOR_STATE_NO_MOVE_WHILE_CULLED, + ETC_TRAIN_WINDOW, + ACTOR_OBJ_BANK_41, + sizeof(TRAIN_WINDOW_ACTOR), + &Train_Window_Actor_ct, + &Train_Window_Actor_dt, + &Train_Window_Actor_move, + &Train_Window_Actor_draw, + NULL +}; + + +static int aTrainWindow_NoDraw(ACTOR*, GAME*); +static int aTrainWindow_DrawGoneOutTunnel(ACTOR*, GAME*); +static int aTrainWindow_DrawInTunnel(ACTOR*, GAME*); + +extern Gfx rom_train_out_tunnel_model[]; +extern Gfx rom_train_out_bgsky_model[]; +extern Gfx rom_train_out_bgcloud_modelT[]; +extern Gfx rom_train_out_bgtree_modelT[]; +extern Gfx rom_train_out_shineglass_modelT[]; + + +static int aTrainWindow_GetTreePalletIdx(){ + static u8 till_data[15][2] = { + { + 0x02,0x03 + }, + { + 0x02,0x11 + }, + { + 0x02,0x18 + }, + { + 0x04,0x03 + }, + { + 0x04,0x08 + }, + { + 0x07,0x16 + }, + { + 0x09,0x0F + }, + { + 0x0A,0x05 + }, + { + 0x0A,0x17 + }, + { + 0x0B,0x07 + }, + { + 0x0B,0x0E + }, + { + 0x0B,0x1C + }, + { + 0x0C,0x0A + }, + { + 0x0C,0x11 + }, + { + 0x0C,0x1F + } + }; + + int i; + lbRTC_month_t month = Common_Get(time.rtc_time.month); + lbRTC_day_t day = Common_Get(time.rtc_time.day); + + for(i = 0; i < 15; i++){ + if (month < till_data[i][0]) { + return i; + } + + if (month == till_data[i][0] && day <= till_data[i][1]) { + return i; + } + } + + return 0; +} + + + +static void Train_Window_Actor_ct(ACTOR* actor, GAME* game){ + TRAIN_WINDOW_ACTOR* window = (TRAIN_WINDOW_ACTOR* )actor; + + switch(Save_Get(scene_no)){ + case 49: + + case 15: + window->draw_type = aTrainWindow_NoDraw; + window->Single_Scrollx = 0; + window->Single_Scrolly = 0; + window->Two_Scrollx1 = 0; + window->Two_Scrolly1 = 0; + window->Two_Scrollx2 = 0; + window->Two_Scrolly2 = 0; + window->scroll_speed = 0.07f; + break; + + case 16: + window->draw_type = aTrainWindow_DrawGoneOutTunnel; + window->Single_Scrollx = 1000; + window->Single_Scrolly = 0; + window->Two_Scrollx1 = 1000; + window->Two_Scrolly1 = 0; + window->Two_Scrollx2 = 0; + window->Two_Scrolly2 = 0; + window->scroll_speed = 1.0f; + break; + } + window->pallete_id = aTrainWindow_GetTreePalletIdx(); + window->current_pallete = aTrainWindow_tree_pal_table[window->pallete_id]; + window->TreeScrollx = 500; + window->TreeScrolly = 0; + window->pos.x = 0; + window->pos.y = 0; + window->pos.z = 0; + window->xlu_alpha = 254.0f; +} + +static void Train_Window_Actor_dt(ACTOR* actor, GAME* game){ + +} + +static u8 aTW_GetNowAlpha(){ + + if((Common_Get(time.now_sec) >= 14400) && (Common_Get(time.now_sec) < 72000)){ + if(Common_Get(time.now_sec) < 43200){ + return 255.0f * ((f32)(Common_Get(time.now_sec) - 14400) / 28800.0f); + } + return 255.0f * (1.0f - ((f32)(Common_Get(time.now_sec) - 43200) / 28800.0f)); + } + else if(Common_Get(time.now_sec) < 14400) { + return 200.0f * (1.0f - (0.5f + ((f32)Common_Get(time.now_sec) / 28800.0f))); + } + else{ + return 200.0f * ((f32)Common_Get(time.now_sec - 72000) / 28800.0f); + } +} + +static void Train_Window_Actor_move(ACTOR* actor, GAME* game){ + TRAIN_WINDOW_ACTOR* window = (TRAIN_WINDOW_ACTOR* )actor; + + f32 alpha; + + window->TreeScrollx += 5; + add_calc(&window->xlu_alpha, aTW_GetNowAlpha(), window->scroll_speed, 50.0f, 1.0f); + if((Common_Get(time.now_sec) < 14400) || (Common_Get(time.now_sec) >= 72000)){ + alpha = 0.0f; + } + else if(Common_Get(time.now_sec) >= 43200){ + alpha = 160.0f + (-160.0f * ((f32)(Common_Get(time.now_sec) - 43200) / 28800.0f)); + } + else{ + alpha = 160.0f * ((f32)(Common_Get(time.now_sec) -14400) / 28800.0f); + } + add_calc(&window->lod_factor, alpha, 0.3f, 50.0f, 1.0f); +} + +static int aTrainWindow_OperateScrollLimit(int a, int b, int c){ + + b >>= 1; + if(b != 0){ + if(b > 0){ + if(a+b > c){ + return c; + } + return a+b; + } + if(b >= 0){ + return a; + } + if(a+b < c){ + return c; + } + return a+b; + } + return a; +} + +static Gfx* aTrainWindow_TileScroll(u32* x, u32* y, int xamt,int yamt, int xend, int yend, +int width, int height, GRAPH** graph){ + + *x = aTrainWindow_OperateScrollLimit(*x, xamt, xend); + *y = aTrainWindow_OperateScrollLimit(*y, yamt, yend); + + return tex_scroll2(*graph, *x, *y, width, height); +} + +static Gfx* aTrainWindow_TileScroll2(u32* x1, u32* y1, int x1amt, int y1amt, int x1end, int y1end, int width1, int height1, +u32* x2, u32* y2, int x2amt, int y2amt, int x2end, int y2end, int width2, int height2, GRAPH** graph){ + + + *x1 = aTrainWindow_OperateScrollLimit(*x1, x1amt, x1end); + *y1 = aTrainWindow_OperateScrollLimit(*y1, y1amt, y1end); + *x2 = aTrainWindow_OperateScrollLimit(*x2, x2amt, x2end); + *y2 = aTrainWindow_OperateScrollLimit(*y2, y2amt, y2end); + + return two_tex_scroll(*graph, 0, *x1, *y1, width1, height1, 1, *x2, *y2, width2, height2); +} + +static int aTrainWindow_DrawGoneOutTunnel(ACTOR* actor, GAME* game){ + TRAIN_WINDOW_ACTOR* window = (TRAIN_WINDOW_ACTOR* )actor; + + GRAPH** graph = &game->graph; + Gfx* ssc; + Gfx* tsc; + + ssc = aTrainWindow_TileScroll(&window->Single_Scrollx,&window->Single_Scrolly, + 0,0,1000,0, 64, 32, graph); + tsc = aTrainWindow_TileScroll2(&window->Two_Scrollx1, &window->Two_Scrolly1, 0,0,1000, 0, 64, 8, + &window->Two_Scrollx2, &window->Two_Scrolly2, 0,0,0,0,16,16,graph); + + if((ssc == NULL) || (tsc == NULL)){ + return 0; + } + else{ + OPEN_DISP(*graph); + + gSPSegment(NOW_POLY_OPA_DISP++, 11, ssc); + gSPSegment(NOW_POLY_XLU_DISP++, 11, ssc); + + gSPSegment(NOW_POLY_OPA_DISP++, 12, tsc); + gSPSegment(NOW_POLY_XLU_DISP++, 12, tsc); + + CLOSE_DISP(*graph); + + return 1; + } +} + +static int aTrainWindow_DrawGoingOutTunnel(ACTOR* actor, GAME* game) { + TRAIN_WINDOW_ACTOR* window = (TRAIN_WINDOW_ACTOR* )actor; + + Gfx* tsc; + Gfx* ssc; + GRAPH** graph = &game->graph; + + ssc = aTrainWindow_TileScroll(&window->Single_Scrollx,&window->Single_Scrolly, + 30,0,1000,0, 64, 32, graph); + tsc = aTrainWindow_TileScroll2(&window->Two_Scrollx1, &window->Two_Scrolly1, 30,0,1000, 0, 64, 8, + &window->Two_Scrollx2, &window->Two_Scrolly2, 0,0,0,0,16,16,graph); + + if((ssc == NULL) || (tsc == NULL)){ + return 0; + } + else{ + OPEN_DISP(*graph); + + gSPSegment(NOW_POLY_OPA_DISP++, 11, ssc); + gSPSegment(NOW_POLY_XLU_DISP++, 11, ssc); + + gSPSegment(NOW_POLY_OPA_DISP++, 12, tsc); + gSPSegment(NOW_POLY_XLU_DISP++, 12, tsc); + + CLOSE_DISP(*graph); + + if(((int)window->Single_Scrollx == 1000) && ((int)window->Two_Scrollx1 == 1000)){ + window->draw_type = aTrainWindow_DrawGoneOutTunnel; + window->pallete_id = aTrainWindow_GetTreePalletIdx(); + window->current_pallete = aTrainWindow_tree_pal_table[window->pallete_id]; + } + + return 1; + } +} + +static int aTrainWindow_NoDraw(ACTOR* actor, GAME* game){ + TRAIN_WINDOW_ACTOR* window = (TRAIN_WINDOW_ACTOR* )actor; + window->draw_type = aTrainWindow_DrawInTunnel; + return 0; +} + +static int aTrainWindow_DrawInTunnel(ACTOR* actor, GAME* game){ + TRAIN_WINDOW_ACTOR* window = (TRAIN_WINDOW_ACTOR* )actor; + + Gfx* tsc; + Gfx* ssc; + GRAPH** graph = &game->graph; + + ssc = aTrainWindow_TileScroll(&window->Single_Scrollx,&window->Single_Scrolly, + 0,0,1000,0, 64, 32, graph); + tsc = aTrainWindow_TileScroll2(&window->Two_Scrollx1, &window->Two_Scrolly1, 0,0,1000, 0, 64, 8, + &window->Two_Scrollx2, &window->Two_Scrolly2, 0,0,0,0,16,16,graph); + + if((ssc == NULL) || (tsc == NULL)){ + return 0; + } + else{ + OPEN_DISP(*graph); + + gSPSegment(NOW_POLY_OPA_DISP++, 11, ssc); + gSPSegment(NOW_POLY_XLU_DISP++, 11, ssc); + + gSPSegment(NOW_POLY_OPA_DISP++, 12, tsc); + gSPSegment(NOW_POLY_XLU_DISP++, 12, tsc); + + CLOSE_DISP(*graph); + + if(Common_Get(sunlight_flag) != 0){ + window->pallete_id = aTrainWindow_GetTreePalletIdx(); + window->current_pallete = aTrainWindow_tree_pal_table[window->pallete_id]; + window->draw_type = aTrainWindow_DrawGoingOutTunnel; + + } + return 1; + } +} + +static void aTrainWindow_SetLightPrimColorDetail(GAME* game, u32 r, u32 g, u32 b, int l, int poly_a, int xlu_a){ + GAME_PLAY* play = (GAME_PLAY*)game; + int i; + int current_color; + u8 color[3]; + GRAPH* graph; + + for(i = 0; i < 3; i++){ + current_color = play->global_light.ambientColor[i] + play->kankyo.ambientColor[i]; + switch(i){ + case 0: + current_color += r; + break; + case 1: + current_color += g; + break; + case 2: + current_color += b; + break; + } + if(current_color < 0){ + current_color = 0; + }else if(current_color >= 256){ + current_color = 255; + } + color[i] = current_color; + } + + if(l < 0){ + l = 0; + }else if(l > 255){ + l = 255; + } + if(poly_a < 0){ + poly_a = 0; + }else if(poly_a > 255){ + poly_a = 255; + } + if(xlu_a < 0){ + xlu_a = 0; + }else if(xlu_a > 255){ + xlu_a = 255; + } + + graph = play->game.graph; + + OPEN_DISP(graph); + gDPSetPrimColor(NOW_POLY_OPA_DISP++, 0, l, color[0], color[1], color[2], poly_a); + gDPSetPrimColor(NOW_POLY_XLU_DISP++, 0, l, color[0], color[1], color[2], xlu_a); + CLOSE_DISP(graph); + +} + +static void aTrainWindow_SetTreeTextureScroll(ACTOR* actor, GAME* game){ + TRAIN_WINDOW_ACTOR* window = (TRAIN_WINDOW_ACTOR* )actor; + Gfx* tree; + + GRAPH** graph = &game->graph; + + tree = tex_scroll2(*graph, window->TreeScrollx, window->TreeScrolly, 128, 32); + + OPEN_DISP(*graph); + + gSPSegment(NOW_POLY_OPA_DISP++,8, tree); + gSPSegment(NOW_POLY_XLU_DISP++,8, tree); + + CLOSE_DISP(*graph); +} + +static void Train_Window_Actor_draw(ACTOR* actor, GAME* game){ + TRAIN_WINDOW_ACTOR* window = (TRAIN_WINDOW_ACTOR* )actor; + + GRAPH* graph = game->graph; + Matrix_translate(0.0f,0.0f,0.0f,FALSE); + Matrix_scale(0.05f, 0.05f, 0.05f, TRUE); + + OPEN_DISP(graph); + + gSPMatrix(NOW_POLY_OPA_DISP++, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(NOW_POLY_XLU_DISP++, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + _texture_z_light_fog_prim(game->graph); + _texture_z_light_fog_prim_xlu(game->graph); + + + if(window->draw_type(actor,game) != 0){ + aTrainWindow_SetLightPrimColorDetail(game, 0,0,0,127,255,(u8)window->xlu_alpha); + gSPSegment(NOW_POLY_XLU_DISP++,10, window->current_pallete); + Evw_Anime_Set(game, &aTrainWindow_evw_anime_data); + aTrainWindow_SetLightPrimColorDetail(game,0,0,0,43,255,window->xlu_alpha); + gSPDisplayList(NOW_POLY_OPA_DISP++,rom_train_out_tunnel_model); + aTrainWindow_SetLightPrimColorDetail(game,0,0,0,127,255,window->xlu_alpha); + gSPDisplayList(NOW_POLY_OPA_DISP++,rom_train_out_bgsky_model); + aTrainWindow_SetLightPrimColorDetail(game,0,0,0,127,255,window->xlu_alpha); + gSPDisplayList(NOW_POLY_XLU_DISP++,rom_train_out_bgcloud_modelT); + aTrainWindow_SetTreeTextureScroll(actor, game); + aTrainWindow_SetLightPrimColorDetail(game, GETREG(CRV, CRV_DEBUG_RED_VALUE) -80 ,GETREG(CRV, CRV_DEBUG_GREEN_VALUE) -70 ,GETREG(CRV, CRV_DEBUG_BLUE_VALUE) -160, GETREG(CRV,CRV_DEBUG_LOD_VALUE) + 27,255, window->xlu_alpha); + gSPDisplayList(NOW_POLY_XLU_DISP++,rom_train_out_bgtree_modelT); + aTrainWindow_SetLightPrimColorDetail(game,0,0,0,window->lod_factor,255,window->xlu_alpha); + gSPDisplayList(NOW_POLY_XLU_DISP++,rom_train_out_shineglass_modelT); + + } + CLOSE_DISP(graph); +} \ No newline at end of file diff --git a/tools/ppcdis b/tools/ppcdis index 29c3a248..396925fc 160000 --- a/tools/ppcdis +++ b/tools/ppcdis @@ -1 +1 @@ -Subproject commit 29c3a24832f4c56daf54714f0c298e503a881bb8 +Subproject commit 396925fc9863001532501a1e0a86689389c2deda