diff options
| author | Leonid Kapitonov <Feacur@gmail.com> | 2024-11-22 15:30:14 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-22 07:30:14 -0700 |
| commit | 0bab7e592c3dcbd4207c2c57c06819ec2b7c1bfa (patch) | |
| tree | 665bc1bf32e3b049cb2136d7ea4190ba00b67ce4 | |
| parent | 9576a6909f4c7ad82f50e042229810bb243a2df3 (diff) | |
`ac_radio` OK (#226)
* prepare unknown size
* move `.data` to the C side
* aRAD_actor_ct OK
* func_80A76B2C_jp OK
* func_80A769E4_jp OK
* aRAD_actor_init OK
* func_80A76958_jp OK (rename to `aRAD_actor_dt`)
* func_80A76A30_jp OK
* func_80A76B4C_jp OK
* aRAD_actor_draw OK
* remove asm pragmas
* document `ac_radio` actions
* rename `func_80A769E4_jp` in accord with aKAG's
* rename `func_80A76B4C_jp` -> `aRAD_actor_move`
* use `StructureActor` as others do
* apply review suggestions
* seems to match too
| -rw-r--r-- | linker_scripts/jp/symbol_addrs_overlays.txt | 17 | ||||
| -rw-r--r-- | linker_scripts/jp/undefined_syms.ld | 4 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_Radio/ac_radio.c | 114 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_Radio/ac_radio.h | 10 | ||||
| -rw-r--r-- | tools/profiles.txt | 2 | ||||
| -rw-r--r-- | yamls/jp/overlays.yaml | 2 |
6 files changed, 121 insertions, 28 deletions
diff --git a/linker_scripts/jp/symbol_addrs_overlays.txt b/linker_scripts/jp/symbol_addrs_overlays.txt index 9747958..60b924d 100644 --- a/linker_scripts/jp/symbol_addrs_overlays.txt +++ b/linker_scripts/jp/symbol_addrs_overlays.txt @@ -18808,21 +18808,20 @@ RO_STR_80A76860_jp = 0x80A76860; // type:asciz // .text aRAD_actor_ct = 0x80A76920; // type:func -func_80A76958_jp = 0x80A76958; // type:func -func_80A769E4_jp = 0x80A769E4; // type:func -func_80A76A30_jp = 0x80A76A30; // type:func -func_80A76B2C_jp = 0x80A76B2C; // type:func -func_80A76B4C_jp = 0x80A76B4C; // type:func +aRAD_actor_dt = 0x80A76958; // type:func +aRAD_set_bgOffset = 0x80A769E4; // type:func +aRAD_wait = 0x80A76A30; // type:func +aRAD_setup_action = 0x80A76B2C; // type:func +aRAD_actor_move = 0x80A76B4C; // type:func aRAD_actor_init = 0x80A76C34; // type:func aRAD_actor_draw = 0x80A76C9C; // type:func // .data Radio_Profile = 0x80A76DD0; // -D_80A76DF4_jp = 0x80A76DF4; // -D_80A76DFC_jp = 0x80A76DFC; // -D_80A76E10_jp = 0x80A76E10; // -D_80A76E1C_jp = 0x80A76E1C; // +aRAD_shadow_vtx_fix_flg_table = 0x80A76DF4; // +aRAD_shadow_data = 0x80A76DFC; // +process = 0x80A76E1C; // allow_duplicated:true // .text diff --git a/linker_scripts/jp/undefined_syms.ld b/linker_scripts/jp/undefined_syms.ld index 7d65c8c..e07480f 100644 --- a/linker_scripts/jp/undefined_syms.ld +++ b/linker_scripts/jp/undefined_syms.ld @@ -4280,7 +4280,9 @@ obj_e_goza_shadowT_model = 0x06001358; // ovl_Radio -D_6054678 = 0x06054678; +aRAD_shadow_vertices = 0x06005B18; +aRAD_shadow_model = 0x06005B98; +aRAD_model = 0x06054678; // ovl__00939090 diff --git a/src/overlays/actors/ovl_Radio/ac_radio.c b/src/overlays/actors/ovl_Radio/ac_radio.c index 652cead..30108c9 100644 --- a/src/overlays/actors/ovl_Radio/ac_radio.c +++ b/src/overlays/actors/ovl_Radio/ac_radio.c @@ -2,13 +2,22 @@ #include "m_actor_dlftbls.h" #include "m_object.h" #include "overlays/gamestates/ovl_play/m_play.h" +#include "macros.h" +#include "m_field_info.h" +#include "src/overlays/actors/player_actor/m_player.h" +#include "m_player_lib.h" +#include "m_rcp.h" void aRAD_actor_ct(Actor* thisx, Game_Play* game_play); -void func_80A76958_jp(Actor* thisx, Game_Play* game_play); +void aRAD_actor_dt(Actor* thisx, Game_Play* game_play); void aRAD_actor_init(Actor* thisx, Game_Play* game_play); void aRAD_actor_draw(Actor* thisx, Game_Play* game_play); -#if 0 +void aRAD_wait(Radio* this, Game_Play* game_play); +void aRAD_setup_action(Radio* this, s32 processIndex); +void aRAD_set_bgOffset(Radio* this, s32 arg1); +void aRAD_actor_move(Actor* thisx, Game_Play* game_play); + ActorProfile Radio_Profile = { /* */ ACTOR_RADIO, /* */ ACTOR_PART_0, @@ -17,25 +26,106 @@ ActorProfile Radio_Profile = { /* */ GAMEPLAY_KEEP, /* */ sizeof(Radio), /* */ aRAD_actor_ct, - /* */ func_80A76958_jp, + /* */ aRAD_actor_dt, /* */ aRAD_actor_init, /* */ aRAD_actor_draw, /* */ NULL, }; -#endif -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Radio/ac_radio/aRAD_actor_ct.s") +extern Vtx aRAD_shadow_vertices[]; +extern Gfx aRAD_shadow_model[]; + +static u8 aRAD_shadow_vtx_fix_flg_table[] = { 1, 0, 0, 1, 0, 1, 1, 0 }; +static ShadowData aRAD_shadow_data = { 8, aRAD_shadow_vtx_fix_flg_table, 60.0f, aRAD_shadow_vertices, + aRAD_shadow_model }; + +void aRAD_actor_ct(Actor* thisx, Game_Play* game_play UNUSED) { + Radio* this = (Radio*)thisx; + aRAD_setup_action(this, RADIO_PROCESS_WAIT); + this->structureActor.unk_2B8 = 0; + aRAD_set_bgOffset(this, 1); +} + +void aRAD_actor_dt(Actor* thisx, Game_Play* game_play UNUSED) { + common_data.clip.structureClip->removeInstanceProc(common_data.clip.structureClip->objectSegmentTable, + ARRAY_COUNT(common_data.clip.structureClip->objectSegmentTable), + STRUCTURE_TYPE_RADIO, thisx); + common_data.clip.structureClip->removeInstanceProc(common_data.clip.structureClip->paletteSegmentTable, + ARRAY_COUNT(common_data.clip.structureClip->paletteSegmentTable), + STRUCTURE_PALETTE_RADIO, thisx); + common_data.clip.structureClip->removeInstanceProc(common_data.clip.structureClip->shadowSegmentTable, + ARRAY_COUNT(common_data.clip.structureClip->shadowSegmentTable), + STRUCTURE_TYPE_RADIO, thisx); +} + +void aRAD_set_bgOffset(Radio* this, s32 arg1) { + // @note: dropping arg1 gets this function matching by itself too, but would break `aRAD_actor_ct` + if (arg1) {} //! FAKE; just like in `aKAG_set_bgOffset` + mCoBG_SetPlussOffset(this->structureActor.actor.home.pos, 3, 100); +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Radio/ac_radio/func_80A76958_jp.s") +void aRAD_wait(Radio* this, Game_Play* game_play) { + xyz_t offsetLocal = { 2.0f, 0.0f, -10.0f }; + xyz_t offsetWorld; + if (this->structureActor.unk_2B8 >= 18) { + this->structureActor.unk_2B8 = 0; + Matrix_push(); + Matrix_translate(this->structureActor.actor.world.pos.x, this->structureActor.actor.world.pos.y, + this->structureActor.actor.world.pos.z, 0); + Matrix_Position(&offsetLocal, &offsetWorld); + Matrix_pull(); + common_data.clip.unk_090->unk_00(0x20, offsetWorld, 1, DEG_TO_BINANG(135), game_play, 0x582B, 1, 0); + } + this->structureActor.unk_2B8 += 1; +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Radio/ac_radio/func_80A769E4_jp.s") +void aRAD_setup_action(Radio* this, s32 processIndex) { + static RadioActionFunc process[] = { aRAD_wait }; + this->structureActor.process = process[processIndex]; + this->structureActor.unk_2B4 = processIndex; +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Radio/ac_radio/func_80A76A30_jp.s") +void aRAD_actor_move(Actor* thisx, Game_Play* game_play) { + Radio* this = (Radio*)thisx; + UNUSED s32 pad; + Player* player = get_player_actor_withoutCheck(game_play); -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Radio/ac_radio/func_80A76B2C_jp.s") + s32 thisBlockX; + s32 thisBlockZ; + s32 playerBlockX; + s32 playerBlockZ; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Radio/ac_radio/func_80A76B4C_jp.s") + mFI_Wpos2BlockNum(&thisBlockX, &thisBlockZ, thisx->world.pos); + mFI_Wpos2BlockNum(&playerBlockX, &playerBlockZ, player->actor.world.pos); + if ((mDemo_Check(1, &player->actor) == 0) && (mDemo_Check(5, &player->actor) == 0) && + ((thisBlockX != playerBlockX) || (thisBlockZ != playerBlockZ))) { + Actor_delete(thisx); + return; + } + ((RadioActionFunc)this->structureActor.process)(this, game_play); +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Radio/ac_radio/aRAD_actor_init.s") +void aRAD_actor_init(Actor* thisx, Game_Play* game_play) { + mFI_SetFG_common(0xF0F5, thisx->home.pos, 0); + aRAD_actor_move(thisx, game_play); + thisx->update = aRAD_actor_move; +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Radio/ac_radio/aRAD_actor_draw.s") +void aRAD_actor_draw(UNUSED Actor* thisx, Game_Play* game_play) { + extern Gfx aRAD_model[]; + GraphicsContext* gfxCtx = game_play->state.gfxCtx; + s32 object = common_data.clip.structureClip->getObjectSegment(STRUCTURE_TYPE_RADIO); + u16* palette = common_data.clip.structureClip->getPalSegment(STRUCTURE_PALETTE_RADIO); + Mtx* mtx = _Matrix_to_Mtx_new(gfxCtx); + if (mtx != NULL) { + _texture_z_light_fog_prim_npc(gfxCtx); + OPEN_POLY_OPA_DISP(gfxCtx); + gSPSegment(__polyOpa++, 0x08, palette); + gSegments[6] = (uintptr_t)OS_PHYSICAL_TO_K0(object); + gSPSegment(__polyOpa++, 0x06, object); + gSPMatrix(__polyOpa++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(__polyOpa++, &aRAD_model); + CLOSE_POLY_OPA_DISP(gfxCtx); + common_data.clip.unk_074->unk_04(game_play, &aRAD_shadow_data, 0x1C); + } +} diff --git a/src/overlays/actors/ovl_Radio/ac_radio.h b/src/overlays/actors/ovl_Radio/ac_radio.h index 387346c..7500d30 100644 --- a/src/overlays/actors/ovl_Radio/ac_radio.h +++ b/src/overlays/actors/ovl_Radio/ac_radio.h @@ -1,18 +1,20 @@ #ifndef AC_RADIO_H #define AC_RADIO_H -#include "ultra64.h" #include "m_actor.h" -#include "unk.h" +#include "overlays/actors/ovl_Structure/ac_structure.h" struct Game_Play; struct Radio; +typedef enum RadioProcess { + RADIO_PROCESS_WAIT, +} RadioProcess; + typedef void (*RadioActionFunc)(struct Radio*, struct Game_Play*); typedef struct Radio { - /* 0x000 */ Actor actor; - /* 0x174 */ UNK_TYPE1 unk_174[0x164]; + /* 0x000 */ StructureActor structureActor; } Radio; // size = 0x2D8 #endif diff --git a/tools/profiles.txt b/tools/profiles.txt index 2c103fe..ed5c734 100644 --- a/tools/profiles.txt +++ b/tools/profiles.txt @@ -532,7 +532,7 @@ asm/jp/data/overlays/actors/ovl_Radio/ac_radio.data.s-/* 937074 80A76DD4 */ .wor asm/jp/data/overlays/actors/ovl_Radio/ac_radio.data.s-/* 937078 80A76DD8 */ .word 0x582B0003 asm/jp/data/overlays/actors/ovl_Radio/ac_radio.data.s-/* 93707C 80A76DDC */ .word 0x000002D8 asm/jp/data/overlays/actors/ovl_Radio/ac_radio.data.s-/* 937080 80A76DE0 */ .word aRAD_actor_ct -asm/jp/data/overlays/actors/ovl_Radio/ac_radio.data.s-/* 937084 80A76DE4 */ .word func_80A76958_jp +asm/jp/data/overlays/actors/ovl_Radio/ac_radio.data.s-/* 937084 80A76DE4 */ .word aRAD_actor_dt asm/jp/data/overlays/actors/ovl_Radio/ac_radio.data.s-/* 937088 80A76DE8 */ .word aRAD_actor_init asm/jp/data/overlays/actors/ovl_Radio/ac_radio.data.s-/* 93708C 80A76DEC */ .word aRAD_actor_draw asm/jp/data/overlays/actors/ovl_Radio/ac_radio.data.s-/* 937090 80A76DF0 */ .word 0x00000000 diff --git a/yamls/jp/overlays.yaml b/yamls/jp/overlays.yaml index 080b4c0..de2742d 100644 --- a/yamls/jp/overlays.yaml +++ b/yamls/jp/overlays.yaml @@ -13167,7 +13167,7 @@ bss_size: 0x0 subsegments: - [0x936BC0, c, overlays/actors/ovl_Radio/ac_radio] - - [0x937070, data, overlays/actors/ovl_Radio/ac_radio] + - [0x937070, .data, overlays/actors/ovl_Radio/ac_radio] - name: ovl_Radio_reloc type: code start: 0x9370C0 |
