link ac_weather_snow

This commit is contained in:
Prakxo
2023-11-06 23:35:24 +01:00
parent a29b551734
commit f472e9b05f
6 changed files with 258 additions and 29 deletions
+4
View File
@@ -556,6 +556,10 @@ ac_weather_rain.c:
.text: [0x80602E70, 0x80603494]
.rodata: [0x8064BB08,0x8064BB30]
.data: [0x806D1DB8, 0x806D1DF8]
ac_weather_snow.c:
.text: [0x80603494, 0x80603B44]
.rodata: [0x8064BB30, 0x8064BB88]
.data: [0x806D1DF8, 0x806D1E10]
m_select.c:
.text: [0x80627F88, 0x80629CA8]
.rodata: [0x8064D1B0, 0x8064D1B8]
+5 -5
View File
@@ -15,7 +15,7 @@ extern ACTOR_PROFILE Weather_Profile;
typedef struct ac_weather_priv_s{
xyz_t pos;
xyz_t speed;
f32 unk18;
f32 currentY;
f32 unk1C;
s16 timer;
s16 work[5];
@@ -26,10 +26,10 @@ typedef struct ac_weather_priv_s{
typedef struct weather_actor_s WEATHER_ACTOR;
typedef void (*CHANGE_WEATHER_PROC)(WEATHER_ACTOR* weather, s16 status, s16 level);
typedef int (*GET_WEATHER_PRV_NUM)(WEATHER_ACTOR* weather);
typedef void (*REMOVE_WEATHER_PRV)(WEATHER_ACTOR* weather, int id);
typedef aWeather_Priv* (*GET_WEATHER_PRV)(u8 status, s16 timer, xyz_t* pos, xyz_t* speed, WEATHER_ACTOR* weather, int id);
typedef void (*CHANGE_WEATHER_PROC)(ACTOR* weather, s16 status, s16 level);
typedef int (*GET_WEATHER_PRV_NUM)(ACTOR* weather);
typedef void (*REMOVE_WEATHER_PRV)(ACTOR* weather, int id);
typedef aWeather_Priv* (*GET_WEATHER_PRV)(u8 status, s16 timer, xyz_t* pos, xyz_t* speed, ACTOR* weather, int id);
typedef int (*WEATHER_SOUND_EFFECT)();
typedef void (*CHANGE_WEATER_INSTANCE_PROC)(WEATHER_ACTOR* weather, s16 status, s16 level);
+12 -9
View File
@@ -86,8 +86,8 @@ static void aWeather_weatherinfo_CommonSet(s16 type, s16 intensity){
Common_Set(weather_intensity, intensity);
}
static void aWeather_RequestChangeWeather(WEATHER_ACTOR* weather, s16 status, s16 level){
static void aWeather_RequestChangeWeather(ACTOR* actor, s16 status, s16 level){
WEATHER_ACTOR* weather = (WEATHER_ACTOR*)actor;
if(mEnv_ReqeustChangeWeatherEnviroment(weather->current_status, status) != 0){
if(status != weather->current_status){
weather->next_status = status;
@@ -102,14 +102,15 @@ static void aWeather_RequestChangeWeather(WEATHER_ACTOR* weather, s16 status, s1
}
void aWeather_RequestChangeWeatherToIsland(){
aWeather_RequestChangeWeather(Common_Get(clip.weather_clip)->actor,Common_Get(island_weather),Common_Get(island_weather_intensity));
aWeather_RequestChangeWeather(&Common_Get(clip.weather_clip)->actor->actor_class,Common_Get(island_weather),Common_Get(island_weather_intensity));
}
void aWeather_RequestChangeWeatherFromIsland(){
aWeather_RequestChangeWeather(Common_Get(clip.weather_clip)->actor, mEnv_SAVE_GET_WEATHER_TYPE(Save_Get(weather)) , mEnv_SAVE_GET_WEATHER_INTENSITY(Save_Get(weather)));
aWeather_RequestChangeWeather(&Common_Get(clip.weather_clip)->actor->actor_class, mEnv_SAVE_GET_WEATHER_TYPE(Save_Get(weather)) , mEnv_SAVE_GET_WEATHER_INTENSITY(Save_Get(weather)));
}
int aWeather_GetWeatherPrvNum(WEATHER_ACTOR* weather){
int aWeather_GetWeatherPrvNum(ACTOR* actor){
WEATHER_ACTOR* weather = (WEATHER_ACTOR*)actor;
aWeather_Priv* priv = weather->priv;
int i;
int num = 0;
@@ -124,7 +125,8 @@ int aWeather_GetWeatherPrvNum(WEATHER_ACTOR* weather){
}
void aWeather_AbolishPrivate(WEATHER_ACTOR* weather, int num){
void aWeather_AbolishPrivate(ACTOR* actor, int num){
WEATHER_ACTOR* weather = (WEATHER_ACTOR*)actor;
aWeather_Priv* priv = weather->priv;
if(priv != NULL){
@@ -135,7 +137,8 @@ void aWeather_AbolishPrivate(WEATHER_ACTOR* weather, int num){
}
}
aWeather_Priv* aWeather_GetWeatherPrv(u8 status, s16 timer, xyz_t* pos, xyz_t* speed, WEATHER_ACTOR* weather, int id){
aWeather_Priv* aWeather_GetWeatherPrv(u8 status, s16 timer, xyz_t* pos, xyz_t* speed, ACTOR* actor, int id){
WEATHER_ACTOR* weather = (WEATHER_ACTOR*)actor;
aWeather_Priv* priv = weather->priv;
if((id != -1) && (id < 100)){
@@ -517,7 +520,7 @@ static void aWeather_MoveWeatherPrv(WEATHER_ACTOR* weather, GAME* game){
if(priv->timer != -100){
priv->timer--;
if(priv->timer <= 0){
aWeather_AbolishPrivate(weather, i);
aWeather_AbolishPrivate(&weather->actor_class, i);
}
}
}
@@ -622,7 +625,7 @@ static void aWeather_ChangeWeatherTime0(WEATHER_ACTOR* weather){
if(((mEv_CheckTitleDemo(rndIntensity) != -9) || ( weather->sound_flag != 1))
&& (mFI_CheckInIsland() == 0)){
aWeather_RequestChangeWeather(weather, rndWeather, rndIntensity);
aWeather_RequestChangeWeather(&weather->actor_class, rndWeather, rndIntensity);
}
Common_Set(weather_time, Common_Get(time.rtc_time));
}
+16 -15
View File
@@ -36,7 +36,8 @@ aWeather_Profile_c iam_weather_rain = {
aWeatherRain_draw,
};
static int aWeatherRain_DecideMakeRainCount(WEATHER_ACTOR* weather){
static int aWeatherRain_DecideMakeRainCount(ACTOR* actor){
WEATHER_ACTOR* weather = (WEATHER_ACTOR*)actor;
if(weather->current_level == 1){
return 1;
@@ -46,24 +47,24 @@ static int aWeatherRain_DecideMakeRainCount(WEATHER_ACTOR* weather){
}
static void aWeatherRain_make(ACTOR* actor, GAME* game){
int i;
int priv_num;
GAME_PLAY* play = (GAME_PLAY*)game;
WEATHER_ACTOR* weather = (WEATHER_ACTOR*)actor;
aWeather_Priv* priv;
xyz_t pos;
xyz_t pos_mod;
xyz_t speed;
int count;
f32 x,y,z;
int i;
int priv_num;
GAME_PLAY* play = (GAME_PLAY*)game;
WEATHER_ACTOR* weather = (WEATHER_ACTOR*)actor;
count = aWeatherRain_DecideMakeRainCount(weather);
f32 x,y,z;
count = aWeatherRain_DecideMakeRainCount(actor);
pos = weather->pos;
for(i = 0; i < count; i++){
priv_num = Common_Get(clip.weather_clip)->get_priv_num(weather);
priv_num = Common_Get(clip.weather_clip)->get_priv_num(&weather->actor_class);
if (priv_num != -1){
x = -130.0f + (RANDOM_F(260.0f));
z = -200.0f + (RANDOM_F(360.0f));
@@ -86,7 +87,7 @@ static void aWeatherRain_make(ACTOR* actor, GAME* game){
pos_mod.y = 70.0f + (120.0f + mCoBG_GetBgY_OnlyCenter_FromWpos(pos_mod, 0.0f));
}
priv = Common_Get(clip.weather_clip)->get_priv(1, 1000, &pos_mod, &speed, (WEATHER_ACTOR*)actor, priv_num);
priv = Common_Get(clip.weather_clip)->get_priv(1, 1000, &pos_mod, &speed, actor, priv_num);
if(priv != NULL){
aWeatherRain_ct(priv,game);
priv->work[0] = 0;
@@ -108,8 +109,8 @@ static void aWeatherRain_MoveRain(aWeather_Priv* priv){
}
static void aWeatherRain_MakePicha(WEATHER_ACTOR* weather, GAME* game, xyz_t pos){
int priv_num = Common_Get(clip.weather_clip)->get_priv_num(weather);
static void aWeatherRain_MakePicha(ACTOR* actor, GAME* game, xyz_t pos){
int priv_num = Common_Get(clip.weather_clip)->get_priv_num(actor);
GAME_PLAY* play = (GAME_PLAY*)game;
aWeather_Priv* priv;
f32 y;
@@ -125,7 +126,7 @@ static void aWeatherRain_MakePicha(WEATHER_ACTOR* weather, GAME* game, xyz_t pos
y = mCoBG_GetBgY_OnlyCenter_FromWpos(pos, 0.0f);
pos.y = y;
}
priv = Common_Get(clip.weather_clip)->get_priv(1, 8, &pos, NULL, weather,priv_num);
priv = Common_Get(clip.weather_clip)->get_priv(1, 8, &pos, NULL, actor, priv_num);
if(priv != NULL){
aWeatherRain_ct(priv,game);
priv->work[0] = 1;
@@ -155,8 +156,8 @@ static void aWeatherRain_move(aWeather_Priv* priv, GAME* game){
if((timer >= 10) && (Common_Get(clip.weather_clip) != NULL)){
weather = Common_Get(clip.weather_clip)->actor;
if(weather != NULL){
(Common_Get(clip.weather_clip)->remove_priv(weather, priv->id));
aWeatherRain_MakePicha(weather, game, priv->pos);
(Common_Get(clip.weather_clip)->remove_priv(&weather->actor_class, priv->id));
aWeatherRain_MakePicha(&weather->actor_class, game, priv->pos);
}
}
}
+221
View File
@@ -0,0 +1,221 @@
#include "ac_weather_snow.h"
#include "main.h"
#include "m_common_data.h"
#include "m_rcp.h"
#include "m_field_info.h"
#include "m_malloc.h"
#include "m_player_lib.h"
#include "sys_matrix.h"
extern Gfx ef_yuki01_setmode[];
extern Gfx ef_yuki01_00_model[];
static void aWeatherSnow_make(ACTOR*, GAME*);
static void aWeatherSnow_ct(aWeather_Priv*, GAME*);
static void aWeatherSnow_move(aWeather_Priv*, GAME*);
static void aWeatherSnow_set(GAME*);
static void aWeatherSnow_draw(aWeather_Priv*, GAME*);
aWeather_Profile_c iam_weather_snow = {
aWeatherSnow_make,
aWeatherSnow_ct,
aWeatherSnow_move,
aWeatherSnow_set,
aWeatherSnow_draw,
};
static int aWeatherSnow_DecideMakeSnowCount(ACTOR* actor, GAME* game){
WEATHER_ACTOR* weather = (WEATHER_ACTOR*)actor;
if(weather->current_level == 1){
return (game->frame_counter & 7) == 0;
}
else if(weather->current_level == 2){
return (game->frame_counter & 3) == 0;
}
return (game->frame_counter & 1);
}
static void aWeatherSnow_make(ACTOR* actor, GAME* game){
WEATHER_ACTOR* weather = (WEATHER_ACTOR*)actor;
GAME_PLAY* play = (GAME_PLAY*)game;
aWeather_Priv* priv;
f32 x,z;
xyz_t pos = weather->pos;
f32 y = 230.0f + pos.y;
int count = Common_Get(clip.weather_clip)->get_priv_num(actor);
xyz_t base = {0.0f, 0.0f, 0.0f};
xyz_t mod_pos;
if(aWeatherSnow_DecideMakeSnowCount(actor, game) != 0){
base.y = -0.5f + (RANDOM_F(-2.0f));
if(count != -1){
x = -100.0f + (RANDOM_F(200.0f));
z = -200.0f + (RANDOM_F(380.0f));
mod_pos = pos;
mod_pos.x += x;
mod_pos.z += z;
mod_pos.y = y;
priv = Common_Get(clip.weather_clip)->get_priv(2, 280, &mod_pos, &base, actor, count);
if(priv != NULL){
aWeatherSnow_ct(priv, game);
priv->work[0]= 0;
priv->work[1] = 156.5f + (RANDOM_F(260.5));
priv->currentY = y;
}
}
}
}
static void aWeatherSnow_ct(aWeather_Priv*, GAME*){
}
static int aWeatherSnow_CheckSnowBorder(aWeather_Priv* priv, GAME_PLAY* play){
WEATHER_ACTOR* weather = Common_Get(clip.weather_clip)->actor;
int ret = 0;
f32 wtemp, ptemp;
if(weather != NULL){
wtemp = weather->pos.x;
ptemp =priv->pos.x;
if(ptemp < (-100.0f + wtemp)){
ret |= 2;
}
if(ptemp > (100.0f + wtemp)){
ret |= 8;
}
wtemp = weather->pos.z;
ptemp =priv->pos.z;
if(ptemp > (180.0f + wtemp)){
ret |= 4;
}
if(ptemp < (-200.0f + wtemp)){
ret |= 1;
}
}
return ret;
}
static void aWeatherSnow_CheckSnowScroll(aWeather_Priv* priv, GAME_PLAY* play){
int border = aWeatherSnow_CheckSnowBorder(priv,play);
PLAYER_ACTOR* player = get_player_actor_withoutCheck(play);
if(border != 0){
if((border >> 1) & 1){
priv->pos.x += 200.0f;
}
if((border >> 3) & 1){
priv->pos.x -= 200.0f;
}
if((border >> 2) & 1){
priv->pos.z -= 380.0f;
}
if(border & 1){
priv->pos.z += 380.0f;
}
}
if(Common_Get(clip.weather_clip) != NULL){
f32 y;
WEATHER_ACTOR* weather = Common_Get(clip.weather_clip)->actor;
if(weather != NULL){
y = 230.0f + weather->pos.y;
if(priv->pos.y < (40.0f + player->actor_class.world.position.y)){
priv->pos.y = (y + (priv->pos.y - priv->currentY));
priv->currentY = y;
}
}
}
}
static void aWeatherSnow_SetWind2Snow(aWeather_Priv* priv){
if(Common_Get(clip.weather_clip) != NULL){
WEATHER_ACTOR* weather = Common_Get(clip.weather_clip)->actor;
if(weather != NULL){
priv->pos.x += weather->wind_info.x;
priv->pos.y += weather->wind_info.y;
priv->pos.z += weather->wind_info.z;
}
}
}
static void aWeatherSnow_move(aWeather_Priv* priv, GAME* game){
GAME_PLAY* play = (GAME_PLAY*) game;
xyz_t_add(&priv->pos,&priv->speed, &priv->pos);
priv->work[0] += priv->work[1];
aWeatherSnow_SetWind2Snow(priv);
aWeatherSnow_CheckSnowScroll(priv,play);
}
static void aWeatherSnow_set(GAME* game){
_texture_z_light_fog_prim_xlu(game->graph);
OPEN_DISP(game->graph);
gSPDisplayList(NEXT_POLY_XLU_DISP, ef_yuki01_setmode);
CLOSE_DISP(game->graph);
}
void aWeatherSnow_draw(aWeather_Priv* priv, GAME* game){
GAME_PLAY* play = (GAME_PLAY*) game;
PLAYER_ACTOR* player = get_player_actor_withoutCheck(play);
xyz_t pos;
xyz_t screen_pos;
Mtx* work;
f32 scale;
f32 min;
pos.x = priv->pos.x + (6.0f * sin_s(priv->work[0]));
pos.y = priv->pos.y;
pos.z = priv->pos.z + (6.0f * cos_s(priv->work[0]));
Game_play_Projection_Trans(play, &pos, &screen_pos);
if((0.0f <= screen_pos.x) && (screen_pos.x < SCREEN_WIDTH_F) && (0.0f <= screen_pos.y) && (screen_pos.y < SCREEN_HEIGHT_F)){
work = GRAPH_ALLOC_TYPE(game->graph, Mtx, 1);
min = pos.y - (40.0f + player->actor_class.world.position.y);
if(min < 0.0f){
min = 0.0f;
}
scale = min / 20.0f;
if(scale > 1.0f){
scale = 1.0f;
}
OPEN_DISP(game->graph);
suMtxMakeTS(work, 0.00195999979042f * scale, 0.00195999979042f * scale, 0.00195999979042f * scale, pos.x, pos.y, pos.z);
gSPMatrix(NEXT_POLY_XLU_DISP, work, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPMatrix(NEXT_POLY_XLU_DISP, play->_208C,G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
gSPDisplayList(NEXT_POLY_XLU_DISP, ef_yuki01_00_model);
CLOSE_DISP( game->graph);
}
}
Regular → Executable
BIN
View File
Binary file not shown.