diff options
| author | Prakxo <87568477+Prakxo@users.noreply.github.com> | 2024-03-22 19:24:09 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-22 11:24:09 -0700 |
| commit | 4b081155a9f62ccc0bf46245cd2219cfb9324cd9 (patch) | |
| tree | 30b799a30f422ad06bd3aabfde5c91aefdf589fc | |
| parent | 87c30f66d2da533d524d67e45c775404f385fba0 (diff) | |
ac_weather_sakura OK (#157)
* weather werk
* ac_weather OK
* format
* review
* sakura werk
* sakura ok
* format
* proto comments
| -rw-r--r-- | include/game.h | 2 | ||||
| -rw-r--r-- | linker_scripts/jp/symbol_addrs_overlays.txt | 12 | ||||
| -rw-r--r-- | linker_scripts/jp/undefined_syms.ld | 4 | ||||
| -rw-r--r-- | src/code/game.c | 4 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_Weather/ac_weather.c | 2 | ||||
| -rw-r--r-- | src/overlays/furniture/ovl_sum_hal_chest02/ac_sum_hal_chest02.c | 2 | ||||
| -rw-r--r-- | src/overlays/weather/ac_weather_sakura/ac_weather_sakura.c | 195 | ||||
| -rw-r--r-- | src/overlays/weather/ac_weather_sakura/ac_weather_sakura.h | 4 | ||||
| -rw-r--r-- | yamls/jp/overlays.yaml | 2 |
9 files changed, 202 insertions, 25 deletions
diff --git a/include/game.h b/include/game.h index 7627ec0..21d67dc 100644 --- a/include/game.h +++ b/include/game.h @@ -58,7 +58,7 @@ typedef struct Game { /* 0x9D */ u8 unk_9D; /* 0x9E */ UNK_TYPE1 unk9E[0x1]; /* 0x9F */ u8 running; - /* 0xA0 */ s32 unk_A0; + /* 0xA0 */ s32 frameCounter; /* 0xA4 */ UNK_TYPE1 unk_A4[0x4]; /* 0xA8 */ Controller controller; } Game; // size = 0xE0 diff --git a/linker_scripts/jp/symbol_addrs_overlays.txt b/linker_scripts/jp/symbol_addrs_overlays.txt index 12a4b41..419dac8 100644 --- a/linker_scripts/jp/symbol_addrs_overlays.txt +++ b/linker_scripts/jp/symbol_addrs_overlays.txt @@ -16167,15 +16167,15 @@ RO_FLT_80A3CFA8_jp = 0x80A3CFA8; // type:f32 // .text -func_80A3D010_jp = 0x80A3D010; // type:func -func_80A3D064_jp = 0x80A3D064; // type:func -func_80A3D238_jp = 0x80A3D238; // type:func +aWeatherSakura_DecideMakeSakuraCount = 0x80A3D010; // type:func +aWeatherSakura_make = 0x80A3D064; // type:func +aWeatherSakura_ct = 0x80A3D238; // type:func func_80A3D2BC_jp = 0x80A3D2BC; // type:func func_80A3D38C_jp = 0x80A3D38C; // type:func func_80A3D484_jp = 0x80A3D484; // type:func -func_80A3D4A0_jp = 0x80A3D4A0; // type:func -func_80A3D530_jp = 0x80A3D530; // type:func -func_80A3D55C_jp = 0x80A3D55C; // type:func +aWeatherSakura_move = 0x80A3D4A0; // type:func +aWeatherSakura_set = 0x80A3D530; // type:func +aWeatherSakura_draw = 0x80A3D55C; // type:func // .data diff --git a/linker_scripts/jp/undefined_syms.ld b/linker_scripts/jp/undefined_syms.ld index 2ce63ba..66556e7 100644 --- a/linker_scripts/jp/undefined_syms.ld +++ b/linker_scripts/jp/undefined_syms.ld @@ -1487,8 +1487,8 @@ D_60000D0 = 0x060000D0; // ac_weather_sakura -D_6000040 = 0x06000040; -D_60000C0 = 0x060000C0; +ef_hanabira01_00_setmode = 0x06000040; +ef_hanabira01_00_modelT = 0x060000C0; // ac_weather_leaf diff --git a/src/code/game.c b/src/code/game.c index a188125..5a3ae33 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -208,7 +208,7 @@ void game_main(Game* game) { gfxCtx->unk_2F0 = 0xA; func_800D2E00_jp(game); - game->unk_A0++; + game->frameCounter++; } void game_init_hyral(Game* game, size_t size) { @@ -263,7 +263,7 @@ void game_ct(Game* game, GameStateFunc init, GraphicsContext* gfxCtx) { mCon_ct(game); - game->unk_A0 = 0; + game->frameCounter = 0; game->main = NULL; game->destroy = NULL; game->running = true; diff --git a/src/overlays/actors/ovl_Weather/ac_weather.c b/src/overlays/actors/ovl_Weather/ac_weather.c index ad807c8..d99d01a 100644 --- a/src/overlays/actors/ovl_Weather/ac_weather.c +++ b/src/overlays/actors/ovl_Weather/ac_weather.c @@ -33,7 +33,7 @@ WeatherOvlInfo profile_tbl[] = { WEATHER_OVERLAY_NONE(ac_weather_fine, &iam_weather_fine), WEATHER_OVERLAY(ac_weather_rain, func_80A3C130_jp, &iam_weather_rain), WEATHER_OVERLAY(ac_weather_snow, func_80A3C890_jp, &iam_weather_snow), - WEATHER_OVERLAY(ac_weather_sakura, func_80A3D010_jp, &iam_weather_sakura), + WEATHER_OVERLAY(ac_weather_sakura, aWeatherSakura_DecideMakeSakuraCount, &iam_weather_sakura), WEATHER_OVERLAY(ac_weather_leaf, func_80A3D7E0_jp, &iam_weather_leaf), }; diff --git a/src/overlays/furniture/ovl_sum_hal_chest02/ac_sum_hal_chest02.c b/src/overlays/furniture/ovl_sum_hal_chest02/ac_sum_hal_chest02.c index 9449156..3fc94f3 100644 --- a/src/overlays/furniture/ovl_sum_hal_chest02/ac_sum_hal_chest02.c +++ b/src/overlays/furniture/ovl_sum_hal_chest02/ac_sum_hal_chest02.c @@ -60,7 +60,7 @@ extern UNK_PTR D_6000000; void aSumHalChest03_dw(FurnitureActor* this, Actor* myRoomActor UNUSED, Game_Play* game_play, u8* data UNUSED) { UNUSED s32 pad; - s32 temp = game_play->state.unk_A0 & 1; + s32 temp = game_play->state.frameCounter & 1; Mtx* mtx = &this->matrix[temp][0]; OPEN_DISPS(game_play->state.gfxCtx); diff --git a/src/overlays/weather/ac_weather_sakura/ac_weather_sakura.c b/src/overlays/weather/ac_weather_sakura/ac_weather_sakura.c index f724af2..08109ae 100644 --- a/src/overlays/weather/ac_weather_sakura/ac_weather_sakura.c +++ b/src/overlays/weather/ac_weather_sakura/ac_weather_sakura.c @@ -1,19 +1,194 @@ -#include "global.h" +#include "ac_weather_sakura.h" +#include "overlays/gamestates/ovl_play/m_play.h" +#include "macros.h" -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/weather/ac_weather_sakura/ac_weather_sakura/func_80A3D010_jp.s") +extern Gfx ef_hanabira01_00_setmode[]; +extern Gfx ef_hanabira01_00_modelT[]; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/weather/ac_weather_sakura/ac_weather_sakura/func_80A3D064_jp.s") +void aWeatherSakura_make(Actor* thisx, Game_Play* play); +void aWeatherSakura_ct(WeatherPrv* priv, Game_Play* play); +void aWeatherSakura_move(WeatherPrv* priv, Game_Play* play); +void aWeatherSakura_set(Game_Play* play); +void aWeatherSakura_draw(WeatherPrv* priv, Game_Play* play); -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/weather/ac_weather_sakura/ac_weather_sakura/func_80A3D238_jp.s") +WeatherProfile iam_weather_sakura = { + aWeatherSakura_make, aWeatherSakura_ct, aWeatherSakura_move, aWeatherSakura_set, aWeatherSakura_draw, +}; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/weather/ac_weather_sakura/ac_weather_sakura/func_80A3D2BC_jp.s") +s32 aWeatherSakura_DecideMakeSakuraCount(Actor* thisx, Game_Play* play) { + Weather* this = (Weather*)thisx; + s32 cur = this->currentLevel; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/weather/ac_weather_sakura/ac_weather_sakura/func_80A3D38C_jp.s") + if (cur == 1) { + if (!(play->state.frameCounter & 3)) { + return 1; + } else { + return 0; + } + } else { + if ((play->state.frameCounter & 1)) { + return 1; + } else { + return 0; + } + } +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/weather/ac_weather_sakura/ac_weather_sakura/func_80A3D484_jp.s") +void aWeatherSakura_make(Actor* thisx, Game_Play* play) { + Weather* this = (Weather*)thisx; + xyz_t pos = this->pos; + f32 y = pos.y + 230.0f; + s32 count = common_data.clip.weatherClip->getPrvNum(thisx); + xyz_t base = { 0.0f, 0.0f, 0.0f }; + UNUSED s32 pad; + WeatherPrv* priv; + f32 x; + f32 z; + xyz_t modPos; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/weather/ac_weather_sakura/ac_weather_sakura/func_80A3D4A0_jp.s") + if (aWeatherSakura_DecideMakeSakuraCount(thisx, play) != 0) { + base.y = -1.6f + (RANDOM_F(-0.19999993f)); + if (count != -1) { + x = -100.0f + (RANDOM_F(200.0f)); + z = -200.0f + (RANDOM_F(380.0f)); -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/weather/ac_weather_sakura/ac_weather_sakura/func_80A3D530_jp.s") + modPos = pos; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/weather/ac_weather_sakura/ac_weather_sakura/func_80A3D55C_jp.s") + modPos.x += x; + modPos.z += z; + modPos.y = y; + + priv = common_data.clip.weatherClip->getPrv(3, 140, &modPos, &base, thisx, count); + if (priv != NULL) { + aWeatherSakura_ct(priv, play); + priv->work[3] = 0; + priv->work[4] = 313.0f + (RANDOM_F(521.0f)); + priv->currentY = y; + } + } + } +} + +void aWeatherSakura_ct(WeatherPrv* priv, UNUSED Game_Play* play) { + priv->work[0] = RANDOM_F(65535.0f); + priv->work[1] = RANDOM_F(65535.0f); + priv->work[2] = RANDOM_F(65535.0f); +} + +s32 aWeatherSakura_CheckSakuraBorder(WeatherPrv* priv) { + UNUSED s32 pad; + Weather* weather = common_data.clip.weatherClip->actor; + s32 ret = 0; + + if (weather != NULL) { + xyz_t pos; + f32 sakuraTemp; + pos = weather->pos; + sakuraTemp = priv->pos.x; + + if (sakuraTemp < (pos.x + (-100.0f))) { + ret |= 2; + } + if (sakuraTemp > (pos.x + (100.0f))) { + ret |= 8; + } + sakuraTemp = priv->pos.z; + + if (sakuraTemp > (pos.z + (180.0f))) { + ret |= 4; + } + if (sakuraTemp < (pos.z + (-200.0f))) { + ret |= 1; + } + } + + return ret; +} + +void aWeatherSakura_CheckSakuraScroll(WeatherPrv* priv) { + s32 border = aWeatherSakura_CheckSakuraBorder(priv); + + 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_data.clip.weatherClip != NULL) { + f32 y; + Weather* weather = common_data.clip.weatherClip->actor; + + if (weather != NULL) { + y = 230.0f + weather->pos.y; + if (priv->pos.y < +weather->pos.y) { + priv->pos.y = (y + (priv->pos.y - priv->currentY)); + priv->currentY = y; + } + } + } +} + +void aWeatherSakura_SetWind2Sakura(WeatherPrv* priv) { + + priv->pos.x += 0.9f; +} + +void aWeatherSakura_move(WeatherPrv* priv, UNUSED Game_Play* play) { + + priv->pos.x += priv->speed.x; + priv->pos.y += priv->speed.y; + priv->pos.z += priv->speed.z; + + priv->work[3] += priv->work[4]; + aWeatherSakura_SetWind2Sakura(priv); + aWeatherSakura_CheckSakuraScroll(priv); + priv->work[0] += 1024; + priv->work[1] += 4536; + priv->work[2] += 2280; +} + +void aWeatherSakura_set(Game_Play* play) { + + OPEN_DISPS(play->state.gfxCtx); + + gSPDisplayList(POLY_XLU_DISP++, ef_hanabira01_00_setmode); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void aWeatherSakura_draw(WeatherPrv* priv, Game_Play* play) { + UNUSED s32 pad; + xyz_t base = { 0.05f, 0.05f, 0.05f }; + xyz_t pos; + xyz_t screenPos; + + pos.x = priv->pos.x + (6.0f * sin_s(priv->work[3])); + + pos.z = priv->pos.z + (6.0f * cos_s(priv->work[3])); + pos.y = priv->pos.y; + Game_play_Projection_Trans(play, &pos, &screenPos); + + if ((screenPos.x >= 0.0f) && (screenPos.x < SCREEN_WIDTH) && (screenPos.y >= 0.0f) && + (screenPos.y < SCREEN_HEIGHT)) { + Mtx* work = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Mtx)); + + OPEN_DISPS(play->state.gfxCtx); + + suMtxMakeSRT(work, base.x, base.y, base.z, priv->work[2], priv->work[1], priv->work[2], pos.x, pos.y, pos.z); + + gSPMatrix(POLY_XLU_DISP++, work, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, ef_hanabira01_00_modelT); + + CLOSE_DISPS(play->state.gfxCtx); + } +} diff --git a/src/overlays/weather/ac_weather_sakura/ac_weather_sakura.h b/src/overlays/weather/ac_weather_sakura/ac_weather_sakura.h index 2158b42..473e2c1 100644 --- a/src/overlays/weather/ac_weather_sakura/ac_weather_sakura.h +++ b/src/overlays/weather/ac_weather_sakura/ac_weather_sakura.h @@ -4,7 +4,9 @@ #include "ultra64.h" #include "overlays/actors/ovl_Weather/ac_weather.h" +struct Game_Play; + extern WeatherProfile iam_weather_sakura; -extern void func_80A3D010_jp(void); +extern s32 aWeatherSakura_DecideMakeSakuraCount(Actor* thisx, struct Game_Play* play); #endif diff --git a/yamls/jp/overlays.yaml b/yamls/jp/overlays.yaml index 4c9ecab..8a9b44b 100644 --- a/yamls/jp/overlays.yaml +++ b/yamls/jp/overlays.yaml @@ -5150,7 +5150,7 @@ bss_size: 0x0 subsegments: - [0x904AB0, c, overlays/weather/ac_weather_sakura/ac_weather_sakura] - - [0x9051A0, data, overlays/weather/ac_weather_sakura/ac_weather_sakura] + - [0x9051A0, .data, overlays/weather/ac_weather_sakura/ac_weather_sakura] - [0x9051D0, .rodata, overlays/weather/ac_weather_sakura/ac_weather_sakura] - name: ac_weather_sakura_reloc type: code |
